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

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]

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]

Properties

Versions 0.1.1, 0.1.1
Change log None available
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 2017-12-04T19:26:13Z

Modules

[Index]

Downloads

Maintainer's Corner

Package maintainers

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)