apiary-2.0.1: Simple and type safe web framework that generate web API documentation.

Safe HaskellNone
LanguageHaskell2010

Control.Monad.Apiary.Filter

Contents

Synopsis

Documentation

type Filter exts actM m inp out = ApiaryT exts out actM m () -> ApiaryT exts inp actM m () Source

routing filter

type Filter' exts actM m = forall prms. Filter exts actM m prms prms Source

routing filter(without modify parameter dictionary)

http method

method :: Monad actM => Method -> Filter' exts actM m Source

filter by HTTP method. since 0.1.0.0.

method GET      -- stdmethod
method "HOGE" -- non standard method

http version

http09 :: Monad actM => Filter' exts actM m Source

http/0.9 only accepted fiter. since 0.5.0.0.

http10 :: Monad actM => Filter' exts actM m Source

http/1.0 only accepted fiter. since 0.5.0.0.

http11 :: Monad actM => Filter' exts actM m Source

http/1.1 only accepted fiter. since 0.5.0.0.

path matcher

root :: (Monad m, Monad actM) => Filter' exts actM m Source

capture :: QuasiQuoter Source

capture QuasiQuoter. since 0.1.0.0.

example:

[capture|/path|] -- first path == "path"
[capture|/int/foo::Int|] -- first path == "int" && get 2nd path as Int.
[capture|/bar::Int/baz::Double|] -- get first path as Int and get 2nd path as Double.
[capture|/**baz|] -- feed greedy and get all path as [Text] (since 0.17.0). 

this QQ can convert pure function easily.

[capture|foofoo::Int|]        == path "path" . fetch (Proxy :: Proxy ("foo" := Int)) . endPath
[capture|barbar::Int/**rest|] == path "path" . fetch (Proxy :: Proxy ("foo" := Int)) . restPath (Proxy :: Proxy "rest")

query matcher

(??) :: proxy key -> Html -> QueryKey key Source

add document to query parameter filter.

[key|key|] ?? "document" =: pInt

(=:) :: (HasDesc query, MonadIO actM, ReqParam v, KnownSymbol k, k </ prms) => query k -> proxy v -> Filter exts actM m prms ((k := v) : prms) Source

get first matched paramerer. since 0.5.0.0.

[key|key|] =: pInt

(=!:) :: (HasDesc query, MonadIO actM, ReqParam v, KnownSymbol k, k </ prms) => query k -> proxy v -> Filter exts actM m prms ((k := v) : prms) Source

get one matched paramerer. since 0.5.0.0.

when more one parameger given, not matched.

[key|key|] =!: pInt

(=?:) :: (HasDesc query, MonadIO actM, ReqParam v, KnownSymbol k, k </ prms) => query k -> proxy v -> Filter exts actM m prms ((k := Maybe v) : prms) Source

get optional first paramerer. since 0.5.0.0.

when illegal type parameter given, fail match(don't give Nothing).

[key|key|] =?: pInt

(=?!:) :: forall query k v exts prms actM m. (HasDesc query, MonadIO actM, Show v, ReqParam v, KnownSymbol k, k </ prms) => query k -> v -> Filter exts actM m prms ((k := v) : prms) Source

get optional first paramerer with default. since 0.16.0.

when illegal type parameter given, fail match(don't give Nothing).

[key|key|] =!?: (0 :: Int)

(=*:) :: (HasDesc query, MonadIO actM, ReqParam v, KnownSymbol k, k </ prms) => query k -> proxy v -> Filter exts actM m prms ((k := [v]) : prms) Source

get many paramerer. since 0.5.0.0.

[key|key|] =*: pInt

(=+:) :: (HasDesc query, MonadIO actM, ReqParam v, KnownSymbol k, k </ prms) => query k -> proxy v -> Filter exts actM m prms ((k := [v]) : prms) Source

get some paramerer. since 0.5.0.0.

[key|key|] =+: pInt

switchQuery :: (HasDesc proxy, MonadIO actM, KnownSymbol k, k </ prms) => proxy k -> Filter exts actM m prms ((k := Bool) : prms) Source

get existance of key only query parameter. since v0.17.0.

header matcher

eqHeader :: (KnownSymbol k, Monad actM) => proxy k -> ByteString -> Filter' exts actM m Source

check whether to exists specified valued header or not. since 0.6.0.0.

header :: (KnownSymbol k, Monad actM, k </ prms) => proxy k -> Filter exts actM m prms ((k := ByteString) : prms) Source

filter by header and get first. since 0.6.0.0.

jsonReqBody :: (KnownSymbol k, MonadIO actM, k </ prms, FromJSON a) => proxy k -> Filter exts actM m prms ((k := a) : prms) Source

filter by JSON typed body. since 2.0.0.

accept :: Monad actM => ContentType -> Filter' exts actM m Source

require Accept header and set response Content-Type. since 0.16.0.

other

ssl :: Monad actM => Filter' exts actM m Source

filter by ssl accessed. since 0.1.0.0.

not export from Web.Apiary

class HasDesc a where Source

Methods

queryDesc :: a key -> Maybe Html Source

newtype QueryKey key Source

Constructors

QueryKey 

query :: forall query strategy k v exts prms actM m. (k </ prms, MonadIO actM, KnownSymbol k, ReqParam v, HasDesc query, Strategy strategy) => query k -> strategy v -> Filter exts actM m prms (SNext strategy k v prms) Source

httpVersion :: Monad actM => HttpVersion -> Html -> Filter' exts actM m Source

http version filter. since 0.5.0.0.

function :: Monad actM => (Doc -> Doc) -> (Store prms -> Request -> Maybe (Store prms')) -> Filter exts actM m prms prms' Source

low level filter function.

function' :: (KnownSymbol key, Monad actM, key </ prms) => (Doc -> Doc) -> (Request -> Maybe (proxy key, prm)) -> Filter exts actM m prms ((key := prm) : prms) Source

filter and append argument.

function_ :: Monad actM => (Doc -> Doc) -> (Request -> Bool) -> Filter' exts actM m Source

filter only(not modify arguments).

focus :: Monad actM => (Doc -> Doc) -> Maybe Method -> (Path prms' (ActionT exts `[]` actM) () -> Path prms (ActionT exts `[]` actM) ()) -> Filter exts actM m prms prms' Source

filter by action. since 1.3.0.