Library
Module
Module type
Parameter
Class
Class type
An opium app provides a set of convenience functions and types to construct a rock app.
val sexp_of_t : t -> Sexplib0.Sexp.t
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 sexp_of_builder : builder -> Sexplib0.Sexp.t
val port : int -> builder
val ssl : cert:string -> key:string -> builder
val cmd_name : string -> builder
type route = string -> Opium_kernel.Rock.Handler.t -> builder
A route is a function that returns a buidler that hooks up a handler to a url mapping
val sexp_of_route : route -> Sexplib0.Sexp.t
val get : route
Method specific routes
val post : route
val delete : route
val put : route
val patch : route
Less common method specific routes
val options : route
val head : route
val any : Cohttp.Code.meth list -> route
any methods
will bind a route to any http method inside of methods
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 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 : Cohttp.Code.meth -> route
val middleware : Opium_kernel.Rock.Middleware.t -> builder
val to_rock : t -> Opium_kernel.Rock.App.t
Convert an opium app to a rock app
val start : t -> unit Lwt.t
Start an opium server. The thread returned can be cancelled to shutdown the server
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 ]
Convenience functions for a running opium app
val json_of_body_exn : Opium_kernel.Rock.Request.t -> Ezjsonm.t Lwt.t
val string_of_body_exn : Opium_kernel.Rock.Request.t -> string Lwt.t
val urlencoded_pairs_of_body :
Opium_kernel.Rock.Request.t ->
(string * string list) list Lwt.t
val param : Opium_kernel.Rock.Request.t -> string -> string
val splat : Opium_kernel.Rock.Request.t -> string list
val respond :
?headers:Cohttp.Header.t ->
?code:Cohttp.Code.status_code ->
body ->
Opium_kernel.Rock.Response.t
val respond' :
?headers:Cohttp.Header.t ->
?code:Cohttp.Code.status_code ->
body ->
Opium_kernel.Rock.Response.t Lwt.t
val redirect :
?headers:Cohttp.Header.t ->
Uri.t ->
Opium_kernel.Rock.Response.t
val redirect' :
?headers:Cohttp.Header.t ->
Uri.t ->
Opium_kernel.Rock.Response.t Lwt.t