The snap-predicates package

[ Tags: library, snap ] [ Propose Tags ]

Provides the definition of a predicate type-class together with several concrete implementations which are used to constrain the set of possible Snap handlers in a type-safe way.


[Skip to Readme]

Properties

Versions 0.1.0, 0.2.0, 0.3.0, 0.3.1
Dependencies attoparsec (>=0.10), base (==4.*), bytestring (>=0.9), case-insensitive (>=1.0), containers (>=0.5), monads-tf (>=0.1), snap-core (>=0.9), text (>=0.11), transformers (>=0.3) [details]
License OtherLicense
Copyright Copyright (c) 2013 Toralf Wittner, Brendan Hay
Author Toralf Wittner, Brendan Hay
Maintainer Toralf Wittner <tw@dtex.org>
Category Snap
Source repository head: git clone git@gitlab.com:twittner/snap-predicates.git
Uploaded Tue Jul 2 18:57:51 UTC 2013 by ToralfWittner
Updated Sun Jan 24 13:03:29 UTC 2016 by ToralfWittner to revision 1   [What is this?]
Distributions NixOS:0.3.1
Downloads 969 total (101 in the last 30 days)
Rating (no votes yet) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]
Hackage Matrix CI

Modules

[Index]

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

For package maintainers and hackage trustees


Readme for snap-predicates-0.3.1

[back to package description]

Snap-Predicates

This library provides the definition of a type-class Predicate together with several concrete implementations which are used to constrain the set of possible Snap handlers in a type-safe way.

A module Snap.Predicates.Tutorial is included, outlining the basic concepts.

Example Usage

main :: IO ()
main = do
    mapM_ putStrLn (showRoutes sitemap)
    quickHttpServe (route . expandRoutes $ sitemap)

sitemap :: Routes Snap ()
sitemap = do
    head_ "/status" (const $ return ())

    get  "/foo" listFoo $
        Accept Text Plain :&: ParamDef "off" 0 :&: ParamDef "size" 100

    post "/foo" createFoo $
        Accept Text Plain :&: ContentType Application Protobuf

listFoo :: MediaType Text Plain :*: Int :*: Int -> Snap ()
listFoo (_mt :*: _off :*: _size) = return ()

createFoo :: MediaType Text Plain :*: Content Application Protobuf -> Snap ()
createFoo (_mt :*: _ct) = return ()