Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Page
Library
Module
Module type
Parameter
Class
Class type
Source
TrailSource# Trail
Trail is a minimalistic, composable framework for building HTTP/S and WebSocket servers, inspired by Plugplug and WebSockwebsock. It provides its users with a small set of abstractions for building _trails_ that can be assembled to handle a request.
To create a Trail, you can use the syntax `Trail.fn1;fn2;fn3;...`, where each function takes a connection object and produces a new connection object.
For example:
```ocaml Trail. logger {level=Debug}; request_id {kind=Uuid_v4}; cqrs_token (); session {salt="3FBYQ5+B"}; (fun conn req -> conn |> send_resp ~status:`OK ~body:"hello world!"); ```
Trail also comes with support for Riotriot, and to start a Trail supervision tree you can call `Trail.start_link ~port trail`.
riot: https://github.com/leostera/riot plug: https://hexdocs.pm/plug/readme.html websock: https://hexdocs.pm/websock/readme.html
The `Conn` module includes functions for handling an ongoing connection.
A trail is a function that given a connection and some options, will produce a new connection object.
The `Trail.t` is the type of the trail _pipelines_.
You can create new pipelines by using the syntax:
```ocaml Trail. logger ~level:Info (); request_id { kind:Uuid_v4 }; my_authentication; my_authorization; my_handler ```
val handler :
Adapter.t ->
(Conn.t -> Conn.t) list ->
Atacama.Connection.t ->
Request.t ->
[> `close | `upgrade of [ `h2c | `websocket of Sock.upgrade_opts * Sock.t ] ]