A web microframework for Haskell based on monadic parsing
Go to file
2022-09-02 20:06:48 +00:00
examples Reorg and rename; replace all request match functions with more general equals and satisfies functions 2022-09-02 20:06:48 +00:00
experimental Remove tests for rewrite 2022-09-01 05:35:25 +00:00
src Reorg and rename; replace all request match functions with more general equals and satisfies functions 2022-09-02 20:06:48 +00:00
test Remove tests for rewrite 2022-09-01 05:35:25 +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 Add new example 2022-09-01 06:36:49 +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 Add new example 2022-09-01 06:36:49 +00:00
README.md Remove MonadIO constraint from MonadOkapi; change how Okapi.Pattern works 2022-08-18 07:26:51 +00:00
release.md Update release.md 2022-08-25 21:00:52 -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 = run 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.