Module Opium.App
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 to_handler : t -> Rock.Handler.tto_handler tconverts the app t to aRockhandler.
val empty : tA basic empty app
type builder= t -> tA builder is a function that transforms an
appby adding some functionality. Builders are usuallys composed with a base app using (|>) to create a full app
val host : string -> builderval backlog : int -> builderbacklogspecifies the maximum number of clients that can have a pending connection request to the Opium server.
val port : int -> builderval ssl : cert:string -> key:string -> builderval cmd_name : string -> builderval not_found : (Request.t -> (Headers.t * Body.t) Lwt.t) -> buildernot_foundaccepts a regular Opium handler that will be used instead of the default 404 handler.
type route= string -> Rock.Handler.t -> builderA route is a function that returns a buidler that hooks up a handler to a url mapping
val get : routeval post : routeval delete : routeval put : routeval options : routeval head : routeval patch : routeval any : Method.t list -> routeany
methodswill bind a route to any http method inside ofmethods
val all : routeall
methodswill bind a route to a URL regardless of the http method. You may escape the actual method used from the request passed.
val action : Method.t -> routeval middleware : Rock.Middleware.t -> builderval start : t -> Lwt_io.server Lwt.tStart an opium server. The thread returned can be cancelled to shutdown the server
val run_command : t -> unitCreate a cmdliner command from an app and run lwt's event loop
val run_command' : t -> [> `Ok of unit Lwt.t | `Error | `Not_running ]