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

[ bsd3, library, web ] [ Propose Tags ] [ Report a vulnerability ]

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]

Modules

[Index]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.1
Dependencies base (>=4.8 && <5), bytestring, http-types, network-uri, servant (>=0.12), text, utf8-string [details]
Tested with ghc ==7.10.3, ghc ==8.0.2, ghc ==8.2.2
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 2017-12-04T19:26:36Z
Distributions NixOS:0.1.1
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 994 total (5 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2017-12-04 [all 1 reports]

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)