A web microframework for Haskell based on monadic parsing
Go to file
2022-09-20 06:43:05 -05:00
docs Add noreferrer 2022-09-12 02:06:45 +00:00
examples Update recipe example to car dealership example 2022-09-18 11:12:51 +00:00
experimental Add new examples 2022-09-15 06:38:42 +00:00
src Update recipe example to car dealership example 2022-09-18 11:12:51 +00:00
test Remove tests for rewrite 2022-09-01 05:35:25 +00:00
.gitignore Get new docs going 2022-09-09 11:06:24 +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 Update recipe example to car dealership example 2022-09-18 11:12:51 +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 Update recipe example to car dealership example 2022-09-18 11:12:51 +00:00
README.md Update README.md 2022-09-20 06:43:05 -05: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 #-}
{-# LANGUAGE TypeApplications #-}

import Data.Text
import Okapi

main :: IO ()
main = run greet

greet = do
  pathParam @Text `is` "greet"
  name <- pathParam @Text
  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 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.