webapi-0.2.2.0: WAI based library for web api

Safe HaskellNone
LanguageHaskell2010

WebApi.Internal

Synopsis

Documentation

data RouteResult a Source

Constructors

NotMatched 
Matched a 

link :: (ToParam (QueryParam m r) QueryParam, MkPathFormatString r, ToParam (PathParam m r) PathParam) => route m r -> URI -> PathParam m r -> Maybe (QueryParam m r) -> URI Source

Generate a type safe URL for a given route type. The URI can be used for setting a base URL if required.

renderPaths :: (ToParam path PathParam, MkPathFormatString r) => path -> route m r -> ByteString Source

class ApiContract (ApiInterface p) m r => ApiHandler p m r where Source

Describes the implementation of a single API end point corresponding to ApiContract (ApiInterface p) m r

Methods

handler :: (query ~ `[]`) => Tagged query p -> Request m r -> HandlerM p (Query (Response m r) query) Source

Handler for the API end point which returns a Response.

TODO : query type parameter is an experimental one used for trying out dependently typed params. This parameter will let us refine the ApiOut to the structure that is requested by the client. for eg : graph.facebook.com/bgolub?fields=id,name,picture

This feature is not finalized and might get changed / removed. Currently the return type of handler is equivalent to `Response m r`

Instances

type family Query t query :: * Source

Equations

Query t `[]` = t 

class (MonadCatch (HandlerM p), MonadIO (HandlerM p), WebApi (ApiInterface p)) => WebApiImplementation p where Source

Binds implementation to interface and provides a pluggable handler monad for the endpoint handler implementation.

Minimal complete definition

Nothing

Associated Types

type HandlerM p :: * -> * Source

Type of the handler Monad. It should implement MonadCatch and MonadIO classes. Defaults to IO.

type ApiInterface p :: * Source

Methods

toIO :: p -> HandlerM p a -> IO a Source

Create a value of IO a from HandlerM p a.

data ServerSettings Source

Type of settings of the server.

Constructors

ServerSettings 

serverSettings :: ServerSettings Source

Default server settings.

data PathSegment Source

Type of segments of a Path.

Constructors

StaticSegment Text

A static segment

Hole

A dynamic segment

class MkPathFormatString r where Source

Describe representation of the route.

Methods

mkPathFormatString :: Proxy r -> [PathSegment] Source

Given a route, this function should produce the [PathSegment] of that route. This gives the flexibility to hook in a different routing system into the application.

Instances

KnownSymbol s => MkPathFormatString (Static s) Source 
MkFormatStr (ToPieces * ((:/) k k1 a b)) => MkPathFormatString ((:/) k k a b) Source 

data ApiException m r Source

Type of Exception raised in a handler.

Constructors

ApiException 

Fields

apiException :: ApiError m r
 

Instances

handleApiException :: (query ~ `[]`, Monad (HandlerM p)) => p -> ApiException m r -> HandlerM p (Query (Response m r) query) Source

handleSomeException :: (query ~ `[]`, Monad (HandlerM p)) => p -> SomeException -> HandlerM p (Query (Response m r) query) Source

newtype Tagged s b Source

Constructors

Tagged 

Fields

unTagged :: b
 

toTagged :: Proxy s -> b -> Tagged s b Source