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 NoArguments
Creates a blank stetson config with default settings and no routes
#cowboyRoutes Source
cowboyRoutes :: forall t a. List Path -> StetsonConfig t a -> StetsonConfig t a
Introduce a list of native Erlang cowboy handlers to this config
#routes Source
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 Source
routes2 :: forall t a rep r. Generic a rep => GDispatch rep r => RouteDuplex t a -> Record r -> RouteConfig t a
#port Source
port :: forall t a. Port -> StetsonConfig t a -> StetsonConfig t a
Set the port that this http listener will listen to
#bindTo Source
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 Source
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 Source
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 Source
tcpOptions :: forall t a. Record ListenOptions -> StetsonConfig t a -> StetsonConfig t a
Supply tcp transport options for cowboy/ranch
#tlsOptions Source
tlsOptions :: forall t a. Record ListenOptions -> StetsonConfig t a -> StetsonConfig t a
Supply tls/ssl transport options for cowboy/ranch
#startClear Source
startClear :: forall t a. String -> StetsonConfig t 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
#StetsonHandler Source
data StetsonHandler msg state
A builder containing the complete set of callbacks for any sort of request
Constructors
StetsonHandler (StetsonHandlerCallbacks msg state)
#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) }
#SimpleStetsonHandler Source
type SimpleStetsonHandler state = StetsonHandler Unit state
A type alias for StetsonHandler, but with no ability to receive messages
#RouteConfig Source
type RouteConfig t a = { dispatch :: a -> RouteHandler, routing :: RouteDuplex t a }
#RestResult Source
data RestResult reply state
The return type of most of the callbacks invoked as part of the REST workflow
Constructors
RestOk reply Req state
RestStop Req state
RestSwitch CowboyHandler Req state
#ProvideHandler Source
type ProvideHandler state = Req -> state -> Effect (RestResult IOData state)
A callback invoked to 'provide' a specific content type
#LoopCallResult Source
#InitHandler Source
type InitHandler state = Req -> Effect (InitResult state)
The callback invoked to kick off the REST workflow
#HandlerArgs Source
data HandlerArgs :: Type
#CowboyHandler Source
data CowboyHandler
The different handlers exposed by Cowboy and loosely mapping onto the Rest/Loop/WebSocket namespaces
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 b c. StetsonHandler b c -> z) -> Exists StetsonRouteInner -> z
#mkStetsonRoute Source
mkStetsonRoute :: forall a s. StetsonHandler a s -> Exists StetsonRouteInner
#emptyHandler Source
emptyHandler :: forall msg state. InitHandler state -> StetsonHandler msg state