okapi/lib
2023-11-09 02:17:01 -08:00
..
src Add tagged middleware 2023-11-09 02:17:01 -08:00
test Remove unecessary code; add basic patterns 2023-07-19 19:16:04 +09:00
.gitignore Major refactor 2023-04-20 06:36:55 +00:00
ChangeLog.md Major refactor 2023-04-20 06:36:55 +00:00
Conduit.postman_collection.json Major refactor 2023-04-20 06:36:55 +00:00
how-to-run-realworld-test.txt Major refactor 2023-04-20 06:36:55 +00:00
HSP.md Major refactor 2023-04-20 06:36:55 +00:00
LICENSE Major refactor 2023-04-20 06:36:55 +00:00
NewDesign.md Update docs; change ResponderHeaders to AddHeader 2023-04-21 05:13:34 +00:00
okapi_1_50.png Major refactor 2023-04-20 06:36:55 +00:00
okapi.cabal Add To/From classes and Parsers/Builders 2023-11-09 01:50:43 -08:00
okapi.png Major refactor 2023-04-20 06:36:55 +00:00
openapi.yml Major refactor 2023-04-20 06:36:55 +00:00
README.md Major refactor 2023-04-20 06:36:55 +00:00
release.md Major refactor 2023-04-20 06:36:55 +00:00
run-api-tests.sh Major refactor 2023-04-20 06:36:55 +00:00
Setup.hs Major refactor 2023-04-20 06:36:55 +00:00
test.db Add JWT foor realworld 2023-04-23 01:16:38 +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.