The snap-predicates package

[Tags: library]

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

Versions0.1.0, 0.2.0, 0.3.0, 0.3.1
Change logNone available
Dependenciesattoparsec (>=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]
LicenseMIT
CopyrightCopyright (c) 2013 Toralf Wittner, Brendan Hay
AuthorToralf Wittner, Brendan Hay
MaintainerToralf Wittner <tw@dtex.org>
Stabilityexperimental
CategorySnap
Source repositoryhead: git clone git://github.com/twittner/snap-predicates.git
UploadedSun May 19 21:36:13 UTC 2013 by ToralfWittner
DistributionsNixOS:0.3.1
Downloads543 total (35 in last 30 days)
Votes
0 []
StatusDocs uploaded by user
Build status unknown [no reports yet]

Modules

[Index]

Downloads

Maintainers' corner

For package maintainers and hackage trustees

Readme for snap-predicates-0.3.0

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 ()