A web microframework for Haskell based on monadic parsing
Go to file
2023-04-16 01:44:41 +00:00
docs Add better support for forms 2022-09-30 18:29:41 +00:00
src Rethink how ResponderHeaders and Responder works 2023-04-16 01:44:41 +00:00
test Rethink how ResponderHeaders and Responder works 2023-04-16 01:44:41 +00:00
.gitignore Add form submission endpoints; more HTML 2022-10-02 20:42:03 +00:00
ChangeLog.md first commit 2022-03-30 00:07:37 +00:00
Conduit.postman_collection.json Transfer all example from old repo 2022-03-30 01:36:29 +00:00
how-to-run-realworld-test.txt Add servant + okapi calculator example 2022-03-30 10:45:29 +00:00
HSP.md Update HSP.md 2022-10-01 22:32:55 -05:00
LICENSE first commit 2022-03-30 00:07:37 +00:00
Main.hs Add new extractors based design 2023-04-05 08:15:39 +00:00
NewDesign.md Add new design doc 2023-04-12 22:08:20 +00:00
okapi_1_50.png Add files via upload 2022-03-30 21:44:17 -05:00
okapi.cabal Add linear types to ResponderHeaders DSL 2023-04-16 00:23:05 +00:00
okapi.png Add files via upload 2022-03-30 21:40:18 -05:00
openapi.yml Transfer all example from old repo 2022-03-30 01:36:29 +00:00
README.md Update README.md 2022-09-20 06:48:42 -05:00
release.md Add better support for forms 2022-09-30 18:29:41 +00:00
run-api-tests.sh Transfer all example from old repo 2022-03-30 01:36:29 +00:00
Setup.hs first commit 2022-03-30 00:07:37 +00:00
todo.db Add better support for forms 2022-09-30 18:29:41 +00:00

Okapi

A micro web framework based on monadic parsing. Official documentation here.

Introduction

Okapi is a micro web framework for Haskell. In contrast to other web frameworks in the Haskell ecosystem, Okapi is primarily concerned with being easy to understand and use, instead of extreme type safety.

Here's an example of a simple web server:

{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeApplications #-}

import Data.Text
import Okapi

main :: IO ()
main = run greet

greet = do
  methodGET
  pathParam @Text `is` "greet"
  name <- pathParam
  pathEnd
  return $ setPlaintext ("Hello " <> name <> "! I'm Okapi.") $ ok

Running this code will start a server on localhost:3000. If you go to http://localhost:3000/greeting/Bob the server will respond with

Hello Bob! I'm Okapi.

in plain text format.

Okapi provides monadic parsers for extracting data from HTTP requests. Since they are monads, parsers can be used with all Applicative, Alternative, and Monad typeclass methods, plus other Haskell idioms like parser combinators. Because of this, parsers are very modular and can be easily composed with one another to fit your specific needs.

With Okapi, and the rest of the Haskell ecosystem, you can create anything from simple website servers to complex APIs for web apps. All you need to get started is basic knowledge about the structure of HTTP requests and an idea of how monadic parsing works.