Module

Stetson

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

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

#configure Source

configure :: StetsonConfig NoArguments

Creates a blank stetson config with default settings and no routes

#cowboyRoutes Source

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

Introduce a list of native Erlang cowboy handlers to this config

#routes Source

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

#port Source

port :: forall a. Int -> StetsonConfig a -> StetsonConfig a

Set the port that this http listener will listen to

#bindTo Source

bindTo :: forall a. Int -> Int -> Int -> Int -> StetsonConfig a -> StetsonConfig a

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

#streamHandlers Source

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

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

#middlewares Source

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

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

#startClear Source

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

Start the listener with the specified name

Re-exports from Stetson.Types

#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

#WebSocketCallResult Source

data WebSocketCallResult state

Return type of most WebSocket callbacks

Constructors

#StetsonHandler Source

data StetsonHandler msg state

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

Constructors

#StetsonConfig Source

type StetsonConfig a = { bindAddress :: Tuple4 Int Int Int Int, bindPort :: Int, cowboyRoutes :: List Path, dispatch :: a -> RouteHandler, middlewares :: Maybe (List NativeModuleName), routing :: RouteDuplex' a, streamHandlers :: Maybe (List NativeModuleName) }

#SimpleStetsonHandler Source

type SimpleStetsonHandler state = StetsonHandler Unit state

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

#RestResult Source

data RestResult reply state

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

Constructors

#ProvideHandler Source

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

A callback invoked to 'provide' a specific content type

#LoopCallResult Source

data LoopCallResult state

Return type of most Loop callbacks

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

#HttpMethod Source

data HttpMethod

or is it a verb

Constructors

Instances

#HandlerArgs Source

#CowboyHandler Source

data CowboyHandler

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

Constructors

#Authorized Source

data Authorized

Return type of the isAuthorized callback

Constructors

#AcceptHandler Source

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

A callback invoked to 'accept' a specific content type

#runStetsonRoute Source

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

#mkStetsonRoute Source

#emptyHandler Source

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