An opium app provides a set of convenience functions and types to construct a rock app.
- Re-exporting common functions needed in handlers
- Easy handling of routes and bodies
- Automatic generation of a command line app
val empty : t
A basic empty app
A builder is a function that transforms an
app by adding some functionality. Builders are usuallys composed with a base app using (|>) to create a full app
val host : string -> builder
val backlog : int -> builder
backlog specifies the maximum number of clients that can have a pending connection request to the Opium server.
val port : int -> builder
val jobs : int -> builder
val cmd_name : string -> builder
not_found accepts a regular Opium handler that will be used instead of the default 404 handler.
A route is a function that returns a buidler that hooks up a handler to a url mapping
Method specific routes
val get : route
val post : route
val delete : route
val put : route
val options : route
val head : route
val patch : route
val all : route
methods will bind a route to a URL regardless of the http method. You may escape the actual method used from the request passed.
Start an opium server. The thread returned can be cancelled to shutdown the server
val start_multicore : t -> unit
Start an opium server with multiple processes.
val run_command : t -> unit
Create a cmdliner command from an app and run lwt's event loop
val run_multicore : t -> unit
Create a cmdliner command from an app and spawn with multiple processes.