Module

Stetson.Types

Package
erl-stetson
Repository
id3as/purescript-erl-stetson

#RestResult Source

data RestResult reply state

The return type of most of the callbacks invoked as part of the REST workflow

Constructors

#InitResult Source

data InitResult state

The return type of the 'init' callback in the REST workflow

Constructors

#InitHandler Source

type InitHandler state = Req -> Effect (InitResult state)

The callback invoked to kick off the REST workflow

#AcceptHandler Source

type AcceptHandler state = Req -> state -> Effect (RestResult Boolean state)

A callback invoked to 'accept' a specific content type

#ProvideHandler Source

type ProvideHandler state = Req -> state -> Effect (RestResult IOData state)

A callback invoked to 'provide' a specific content type

#WebSocketInitHandler Source

type WebSocketInitHandler msg state = state -> WebSocketResult msg (WebSocketCallResult state)

Callback used to kick off the WebSocket handler This is a good time to get hold of 'self' and set up subscriptions

#WebSocketInfoHandler Source

type WebSocketInfoHandler msg state = msg -> state -> WebSocketResult msg (WebSocketCallResult state)

Callback used to handle messages sent from Erlang (hopefully via the router) so they'll be of the right type

#WebSocketHandleHandler Source

type WebSocketHandleHandler msg state = Frame -> state -> WebSocketResult msg (WebSocketCallResult state)

Callback used to handle messages sent from the client in the form of 'Frames' which will need unpacking/decoding/parsing etc

#WebSocketResult Source

type WebSocketResult msg r = ResultT msg r

All of the Loop handlers take place in a ReaderT so we can do things like get the current pid

#WebSocketCallResult Source

data WebSocketCallResult state

Return type of most WebSocket callbacks

Constructors

#HttpMethod Source

data HttpMethod

or is it a verb

Constructors

Instances

#Authorized Source

data Authorized

Return type of the isAuthorized callback

Constructors

#StetsonHandler Source

data StetsonHandler msg state

A builder containing the complete set of callbacks for any sort of request

Constructors

#SimpleStetsonHandler Source

type SimpleStetsonHandler state = StetsonHandler Unit state

A type alias for StetsonHandler, but with no ability to receive messages

#StetsonHandlerCallbacks Source

type StetsonHandlerCallbacks msg state = { allowMissingPost :: Maybe (Req -> state -> Effect (RestResult Boolean state)), allowedMethods :: Maybe (Req -> state -> Effect (RestResult (List HttpMethod) state)), contentTypesAccepted :: Maybe (Req -> state -> Effect (RestResult (List (Tuple2 String (AcceptHandler state))) state)), contentTypesProvided :: Maybe (Req -> state -> Effect (RestResult (List (Tuple2 String (ProvideHandler state))) state)), deleteResource :: Maybe (Req -> state -> Effect (RestResult Boolean state)), forbidden :: Maybe (Req -> state -> Effect (RestResult Boolean state)), init :: Req -> Effect (InitResult state), isAuthorized :: Maybe (Req -> state -> Effect (RestResult Authorized state)), isConflict :: Maybe (Req -> state -> Effect (RestResult Boolean state)), loopInfo :: Maybe (LoopInfoHandler msg state), loopInit :: Maybe (LoopInitHandler msg state), malformedRequest :: Maybe (Req -> state -> Effect (RestResult Boolean state)), movedPermanently :: Maybe (Req -> state -> Effect (RestResult MovedResult state)), movedTemporarily :: Maybe (Req -> state -> Effect (RestResult MovedResult state)), previouslyExisted :: Maybe (Req -> state -> Effect (RestResult Boolean state)), resourceExists :: Maybe (Req -> state -> Effect (RestResult Boolean state)), serviceAvailable :: Maybe (Req -> state -> Effect (RestResult Boolean state)), terminate :: Maybe (Foreign -> Req -> state -> Effect Unit), wsHandle :: Maybe (WebSocketHandleHandler msg state), wsInfo :: Maybe (WebSocketInfoHandler msg state), wsInit :: Maybe (WebSocketInitHandler msg state) }

The built record containing callbacks for any sort of request

#CowboyRoutePlaceholder Source

#HandlerArgs Source

#StetsonConfig Source

type StetsonConfig t a = { bindAddress :: Ip4Address, bindPort :: Port, cowboyRoutes :: List Path, middlewares :: Maybe (List NativeModuleName), routes :: RouteConfig t a, streamHandlers :: Maybe (List NativeModuleName), tcpOptions :: Maybe (Record ListenOptions), tlsOptions :: Maybe (Record ListenOptions) }

#RouteConfig Source

type RouteConfig t a = { dispatch :: a -> RouteHandler, routing :: RouteDuplex t a }

#RouteHandler2 Source

type RouteHandler2 msg state = Config state (OptionalConfig Maybe msg state)

#Config Source

type Config :: Type -> Row Type -> Typetype Config state r = { init :: Req -> Effect (InitResult state) | r }

#OptionalConfig Source

type OptionalConfig :: (Type -> Type) -> Type -> Type -> Row Typetype OptionalConfig f msg state = (allowMissingPost :: RequestHandler f Boolean state, allowedMethods :: RequestHandler f (List HttpMethod) state, contentTypesAccepted :: RequestHandler f (List (Tuple2 String (AcceptHandler state))) state, contentTypesProvided :: RequestHandler f (List (Tuple2 String (ProvideHandler state))) state, deleteResource :: RequestHandler f Boolean state, forbidden :: RequestHandler f Boolean state, isAuthorized :: RequestHandler f Authorized state, isConflict :: RequestHandler f Boolean state, loopInfo :: f (LoopInfoHandler msg state), loopInit :: f (LoopInitHandler msg state), malformedRequest :: RequestHandler f Boolean state, movedPermanently :: RequestHandler f MovedResult state, movedTemporarily :: RequestHandler f MovedResult state, previouslyExisted :: RequestHandler f Boolean state, resourceExists :: RequestHandler f Boolean state, serviceAvailable :: RequestHandler f Boolean state, terminate :: f (Foreign -> Req -> state -> Effect Unit), wsHandle :: f (WebSocketHandleHandler msg state), wsInfo :: f (WebSocketInfoHandler msg state), wsInit :: f (WebSocketInitHandler msg state))

#RequestHandler Source

type RequestHandler :: (Type -> Type) -> Type -> Type -> Typetype RequestHandler f resultType state = f (Req -> state -> Effect (RestResult resultType state))

#StetsonRouteInner Source

#CowboyHandler Source

data CowboyHandler

The different handlers exposed by Cowboy and loosely mapping onto the Rest/Loop/WebSocket namespaces

Constructors

#LoopInitHandler Source

type LoopInitHandler msg state = Req -> state -> LoopResult msg state

Callback used to kick off the Loop handler, it is here where subscriptions should be created, and in their callbacks the messages should be passed into the router for dealing with in the info callback

#LoopInfoHandler Source

type LoopInfoHandler msg state = msg -> Req -> state -> LoopResult msg (LoopCallResult state)

Callback used to handle messages sent from Erlang (hopefully via the router) so they'll be of the right type

#LoopResult Source

type LoopResult msg r = ResultT msg r

All of the Loop handlers take place in a ReaderT so we can do things like get the current pid

#LoopCallResult Source

data LoopCallResult state

Return type of most Loop callbacks

Constructors

#mkStetsonRoute Source

#runStetsonRoute Source

runStetsonRoute :: forall z. (forall b c. StetsonHandler b c -> z) -> Exists StetsonRouteInner -> z

#emptyHandler Source

emptyHandler :: forall msg state. InitHandler state -> StetsonHandler msg state

#routeHandler Source

routeHandler :: forall optional trash msg state. Union optional trash (OptionalConfig Unlift msg state) => Config state optional -> StetsonHandler msg state

#unwrapResult Source

unwrapResult :: forall msg result. ResultT msg result -> (ReaderT (Process msg) Effect result)

#ResultT Source

newtype ResultT msg result

Instances