webgear-core-1.0.4: Composable, type-safe library to build HTTP APIs
Safe HaskellSafe-Inferred
LanguageHaskell2010

WebGear.Core.Handler

Description

WebGear handlers

Synopsis

Documentation

class (ArrowChoice h, ArrowPlus h, ArrowError RouteMismatch h, Monad m) => Handler h m | h -> m where Source #

A handler is an arrow with a monadic context.

Handlers have the following capabilities:

  • Lift a monadic action into a handler arrow.
  • Implement ArrowChoice typeclass so that conditionals can be used in arrow code.
  • Implement ArrowPlus for routing requests to specific handlers.
  • Provide contextual documentation elements - description and summary

Methods

arrM :: (a -> m b) -> h a b Source #

Lift a monadic function to a handler arrow

consumeRoute :: h RoutePath a -> h () a Source #

Consume all remaining path components with an arrow

setDescription :: Description -> h a a Source #

Set a description of a part of an API

setSummary :: Summary -> h a a Source #

Set a summary of a part of an API

newtype RoutePath Source #

Parts of the request path used by the routing machinery

Constructors

RoutePath [Text] 

Instances

Instances details
IsList RoutePath Source # 
Instance details

Defined in WebGear.Core.Handler

Associated Types

type Item RoutePath #

Show RoutePath Source # 
Instance details

Defined in WebGear.Core.Handler

Eq RoutePath Source # 
Instance details

Defined in WebGear.Core.Handler

type Item RoutePath Source # 
Instance details

Defined in WebGear.Core.Handler

newtype Summary Source #

A summary associated with part of an API

Constructors

Summary 

Fields

Instances

Instances details
IsString Summary Source # 
Instance details

Defined in WebGear.Core.Handler

Methods

fromString :: String -> Summary #

Read Summary Source # 
Instance details

Defined in WebGear.Core.Handler

Show Summary Source # 
Instance details

Defined in WebGear.Core.Handler

Eq Summary Source # 
Instance details

Defined in WebGear.Core.Handler

Methods

(==) :: Summary -> Summary -> Bool #

(/=) :: Summary -> Summary -> Bool #

Ord Summary Source # 
Instance details

Defined in WebGear.Core.Handler

type RequestHandler h req = h (Linked req Request) Response Source #

A handler arrow from a linked request to response.

type Middleware h reqOut reqIn = RequestHandler h reqIn -> RequestHandler h reqOut Source #

A middleware enhances a RequestHandler and produces another handler.

routeMismatch :: ArrowError RouteMismatch h => h a b Source #

Indicates that the request does not match the current handler.

unlinkA :: Handler h m => h (Linked ts Response) Response Source #

Lifts unlink into a handler arrow.