Module

Stetson

This is the entry point into the Stetson wrapper You'll want to call Stetson.configure and then follow the types..

#configure

configure :: StetsonConfig NoArguments NoArguments

Creates a blank stetson config with default settings and no routes

#cowboyRoutes

cowboyRoutes :: forall t a. List Path -> StetsonConfig t a -> StetsonConfig t a

Introduce a list of native Erlang cowboy handlers to this config

#routes

routes :: forall t' a' t a rep r. Generic a rep => GDispatch rep r => RouteDuplex t a -> Record r -> StetsonConfig t' a' -> StetsonConfig t a

#routes2

routes2 :: forall t a rep r. Generic a rep => GDispatch rep r => RouteDuplex t a -> Record r -> RouteConfig t a

#port

port :: forall t a. Port -> StetsonConfig t a -> StetsonConfig t a

Set the port that this http listener will listen to

#bindTo

bindTo :: forall t a. Ip4Address -> StetsonConfig t a -> StetsonConfig t a

Set the IP that this http listener will bind to (default: 0.0.0.0)

#streamHandlers

streamHandlers :: forall t a. List NativeModuleName -> StetsonConfig t a -> StetsonConfig t a

Supply a list of modules to act as native stream handlers in cowboy

#middlewares

middlewares :: forall t a. List NativeModuleName -> StetsonConfig t a -> StetsonConfig t a

Supply a list of modules to act as native middlewares in cowboy

#tcpOptions

tcpOptions :: forall t a. Record ListenOptions -> StetsonConfig t a -> StetsonConfig t a

Supply tcp transport options for cowboy/ranch

#tlsOptions

tlsOptions :: forall t a. Record ListenOptions -> StetsonConfig t a -> StetsonConfig t a

Supply tls/ssl transport options for cowboy/ranch

#startClear

startClear :: forall t a. String -> StetsonConfig t a -> Effect (Either Foreign Unit)

Start the listener with the specified name

#startTls

startTls :: forall t a. String -> StetsonConfig t a -> Effect (Either Foreign Unit)

Start the TLS listener with the specified name

#stop

Re-exports from Stetson.Types

#WebSocketInitHandler

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

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

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

#WebSocketCallResult

data WebSocketCallResult state

Return type of most WebSocket callbacks

Constructors

#StetsonHandler

data StetsonHandler msg state

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

Constructors

#StetsonConfig

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

#StaticAssetLocation

#SimpleStetsonHandler

type SimpleStetsonHandler state = StetsonHandler Unit state

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

#RouteConfig

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

#RestResult

data RestResult reply state

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

Constructors

#ProvideHandler

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

A callback invoked to 'provide' a specific content type

#LoopCallResult

data LoopCallResult state

Return type of most Loop callbacks

Constructors

#InitResult

data InitResult state

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

Constructors

#InitHandler

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

The callback invoked to kick off the REST workflow

#HttpMethod

data HttpMethod

or is it a verb

Constructors

Instances

#HandlerArgs

#CowboyHandler

data CowboyHandler

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

Constructors

#Authorized

data Authorized

Return type of the isAuthorized callback

Constructors

#AcceptHandlerResult

data AcceptHandlerResult

The return result of an AcceptHandler (success/failure/success with url)

#AcceptHandler

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

A callback invoked to 'accept' a specific content type

#runStetsonRoute

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

#mkStetsonRoute

#emptyHandler

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

#acceptSuccessLocation

acceptSuccessLocation :: String -> AcceptHandlerResult

The resource was accepted succesfully And here is the URI of its new location

#acceptSuccess

acceptSuccess :: AcceptHandlerResult

The resource was accepted succesfully

#acceptFailure

acceptFailure :: AcceptHandlerResult

The resource was not accepted

Modules