servant-match: Standalone implementation of servant’s dispatching mechanism

[ bsd3, library, web ] [ Propose Tags ]

This package provides a standalone implementation of dispatching a function by matching it against a Servant API. A common usecase for this is to convert an URI to an ADT that provides a more structured representation of the URL.


[Skip to Readme]
Versions 0.1.1
Dependencies base (>=4.8 && <5), bytestring, http-types, network-uri, servant (>=0.12), text, utf8-string [details]
License BSD-3-Clause
Copyright (C) 2017 Moritz Kiefer
Author Moritz Kiefer
Maintainer moritz.kiefer@purelyfunctional.org
Category Web
Home page https://github.com/cocreature/servant-match#readme
Source repo head: git clone https://github.com/cocreature/servant-match
Uploaded by cocreature at Mon Dec 4 19:26:36 UTC 2017
Distributions NixOS:0.1.1
Downloads 163 total (5 in the last 30 days)
Rating (no votes yet) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2017-12-04 [all 1 reports]
Hackage Matrix CI

Modules

[Index]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


Readme for servant-match-0.1.1

[back to package description]

servant-match

Travis Hackage

This package provides a standalone implementation of dispatching a function by matching it against a Servant API. A common usecase for this is to convert an URI to an ADT that provides a more structured representation of the URL.

Usage

data DataView
  = Show
  | Edit
  deriving (Show, Eq)

data View
  = ViewUsers
  | ViewNewUser
  | ViewUser !Text !DataView
  deriving (Show, Eq)

data User = User

type API =
  "users" :> (Get '[JSON] [User] :<|> "new" :> ReqBody '[JSON] User :> Post '[JSON] User) :<|>
  "user" :> Capture "user" Text :>
    (Get '[JSON] User :<|>
     "edit" :> ReqBody '[JSON] User :> Put '[JSON] User)

parser :: MatchT API View
parser =
  (ViewUsers :<|> ViewNewUser) :<|> (\u -> ViewUser u Show :<|> ViewUser u Edit)