opium

OCaml web framework
IN THIS PACKAGE
Module Opium . App
type t

An opium app is a simple builder wrapper around a rock app

val to_handler : t -> Rock.Handler.t

to_handler t converts the app t to a Rock handler.

val empty : t

A basic empty app

type builder = t -> t

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
val not_found : ( Request.t -> (Headers.t * Body.t) Lwt.t ) -> builder

not_found accepts a regular Opium handler that will be used instead of the default 404 handler.

type route = string -> Rock.Handler.t -> builder

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 any : Method.t list -> route

any methods will bind a route to any http method inside of methods

val all : route

all methods will 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 -> route
val middleware : Rock.Middleware.t -> builder
val start : t -> Lwt_io.server Lwt.t

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_command' : t -> [> `Ok of unit Lwt.t | `Error | `Not_running ]
val run_multicore : t -> unit

Create a cmdliner command from an app and spawn with multiple processes.