A web microframework for Haskell based on monadic parsing
Go to file
2022-08-15 01:49:45 +00:00
examples Reorg modules again; finalize imports & exports 2022-08-06 05:21:53 +00:00
experimental Move experimental modules into separate folder 2022-08-15 01:49:45 +00:00
src Move experimental modules into separate folder 2022-08-15 01:49:45 +00:00
test Add pathWildcard parser; add more doctests 2022-08-07 01:46:57 +00:00
.gitignore Make first Hackage release 2022-05-30 08:51:05 +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
LICENSE first commit 2022-03-30 00:07:37 +00:00
okapi_1_50.png Add files via upload 2022-03-30 21:44:17 -05:00
okapi.cabal Move experimental modules into separate folder 2022-08-15 01:49:45 +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
package.yaml Move experimental modules into separate folder 2022-08-15 01:49:45 +00:00
README.md Update README.md 2022-07-26 22:52:57 -05: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
stack.yaml Make first Hackage release 2022-05-30 08:51:05 +00:00
stack.yaml.lock Working on sse implementation 2022-04-19 03:02:47 +00:00
todo.db Implement todo example 2022-07-29 09:37:08 +00:00

Okapi

A microframework based on monadic parsing. Official documentation here.

Introduction

Okapi is a microframework for building web servers using parsers. 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 #-}

import Data.Text
import Okapi

main :: IO ()
main = runOkapi id 3000 greet

greet = do
  pathSeg "greet"
  name <- pathParam
  okPlainText [] $ "Hello " <> name <> "! I'm Okapi."

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 your 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.