okapi: A micro web framework based on monadic parsing

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

Please see the README on GitHub at https://github.com/monadicsystems/okapi#readme


[Skip to Readme]

Properties

Versions 0.1.0.0, 0.1.0.1, 0.1.0.2, 0.2.0.0
Change log ChangeLog.md
Dependencies aeson (>=2.0.3.0 && <2.1), attoparsec (>=0.14.4 && <0.15), base (>=4.7 && <5), base64 (>=0.4.2.3 && <0.5), bytestring (>=0.10.12.1 && <0.11), containers (>=0.6.4.1 && <0.7), cookie (>=0.4.5 && <0.5), cryptonite (>=0.29 && <0.30), extra (>=1.7.10 && <1.8), http-api-data (>=0.4.3 && <0.5), http-types (>=0.12.3 && <0.13), interpolatedstring-perl6 (>=1.0.2 && <1.1), memory (>=0.16.0 && <0.17), mmorph (>=1.1.5 && <1.2), mtl (>=2.2.2 && <2.3), network (>=3.1.2.7 && <3.2), okapi, parser-combinators (>=1.3.0 && <1.4), random (>=1.2.1 && <1.3), rel8 (>=1.3.1.0 && <1.4), slave-thread (>=1.1.0.1 && <1.2), sqlite-simple (>=0.4.18.0 && <0.5), text (>=1.2.5.0 && <1.3), time (>=1.9.3 && <1.10), transformers (>=0.5.6.2 && <0.6), unagi-chan (>=0.4.1.4 && <0.5), vault (>=0.3.1.5 && <0.4), wai (>=3.2.3 && <3.3), wai-extra (>=3.1.8 && <3.2), wai-websockets (>=3.0.1.2 && <3.1), warp (>=3.3.20 && <3.4), warp-tls (>=3.3.2 && <3.4), websockets (>=0.12.7.3 && <0.13) [details]
License BSD-3-Clause
Copyright 2022 Monadic Systems LLC
Author Monadic Systems LLC
Maintainer tech@monadic.systems
Category Web
Home page https://github.com/monadicsystems/okapi#readme
Bug tracker https://github.com/monadicsystems/okapi/issues
Source repo head: git clone https://github.com/monadicsystems/okapi
Uploaded by rashad1030 at 2022-09-20T12:31:38Z

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Readme for okapi-0.2.0.0

[back to package description]

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.