package yurt

  1. Overview
  2. Docs

Module Yurt.ServerSource

Server contains the methods needed to build a Yurt server

include Cohttp_lwt.S.Server with module IO = Cohttp_lwt_unix.IO
module IO : sig ... end
type conn = IO.conn * Cohttp.Connection.t
type response_action = [
  1. | `Expert of Cohttp.Response.t * (IO.ic -> IO.oc -> unit Lwt.t)
  2. | `Response of Cohttp.Response.t * Cohttp_lwt__.Body.t
]
type t
val make_response_action : ?conn_closed:(conn -> unit) -> callback: (conn -> Cohttp.Request.t -> Cohttp_lwt__.Body.t -> response_action Lwt.t) -> unit -> t
val make_expert : ?conn_closed:(conn -> unit) -> callback: (conn -> Cohttp.Request.t -> Cohttp_lwt__.Body.t -> (Cohttp.Response.t * (IO.ic -> IO.oc -> unit Lwt.t)) Lwt.t) -> unit -> t
val make : ?conn_closed:(conn -> unit) -> callback: (conn -> Cohttp.Request.t -> Cohttp_lwt__.Body.t -> (Cohttp.Response.t * Cohttp_lwt__.Body.t) Lwt.t) -> unit -> t
val resolve_local_file : docroot:string -> uri:Uri.t -> string
val respond : ?headers:Cohttp.Header.t -> ?flush:bool -> status:Cohttp.Code.status_code -> body:Cohttp_lwt__.Body.t -> unit -> (Cohttp.Response.t * Cohttp_lwt__.Body.t) Lwt.t
val respond_string : ?flush:bool -> ?headers:Cohttp.Header.t -> status:Cohttp.Code.status_code -> body:string -> unit -> (Cohttp.Response.t * Cohttp_lwt__.Body.t) Lwt.t
val respond_error : ?headers:Cohttp.Header.t -> ?status:Cohttp.Code.status_code -> body:string -> unit -> (Cohttp.Response.t * Cohttp_lwt__.Body.t) Lwt.t
val respond_redirect : ?headers:Cohttp.Header.t -> uri:Uri.t -> unit -> (Cohttp.Response.t * Cohttp_lwt__.Body.t) Lwt.t
val respond_need_auth : ?headers:Cohttp.Header.t -> auth:Cohttp.Auth.challenge -> unit -> (Cohttp.Response.t * Cohttp_lwt__.Body.t) Lwt.t
val respond_not_found : ?uri:Uri.t -> unit -> (Cohttp.Response.t * Cohttp_lwt__.Body.t) Lwt.t
val callback : t -> IO.conn -> IO.ic -> IO.oc -> unit Lwt.t
Sourceval resolve_file : docroot:string -> uri:Uri.t -> string
Sourcetype server = {
  1. host : string;
  2. port : int;
  3. mutable routes : (string * Route.route * endpoint) list;
  4. mutable tls_config : Conduit_lwt_unix.server_tls_config option;
  5. mutable logger : Lwt_log.logger;
}
Sourceval server : ?tls_config:Conduit_lwt_unix.server_tls_config -> ?logger:Lwt_log.logger -> string -> int -> server

Create a new server

Sourceval server_from_config : string -> server

Create a new server from an existing configuration file

Sourceval log_debug : server -> string -> string -> unit
Sourceval log_info : server -> string -> string -> unit
Sourceval log_notice : server -> string -> string -> unit
Sourceval log_error : server -> string -> string -> unit
Sourceval log_fatal : server -> string -> string -> unit
Sourceval configure_tls : ?password:[ `Password of bool -> string | `No_password ] -> server -> string -> string -> server

Configure TLS after the server has been created

Sourceval stream : ?flush:bool -> ?headers:Header.t -> ?status:int -> string Lwt_stream.t -> (Response.t * Body.t) Lwt.t

Respond with a stream

Sourceval json : ?flush:bool -> ?headers:Header.t -> ?status:int -> Ezjsonm.t -> (Response.t * Body.t) Lwt.t

Respond with JSON data

Sourceval html : ?flush:bool -> ?headers:Header.t -> ?status:int -> Yurt_html.t -> (Response.t * Body.t) Lwt.t

Respond with HTML data

Sourceval string : ?flush:bool -> ?headers:Header.t -> ?status:int -> string -> (Response.t * Body.t) Lwt.t

Respond with string data

Sourceval redirect : ?headers:Header.t -> string -> (Response.t * Body.t) Lwt.t

Redirect client

Sourceval file : ?headers:Header.t -> string -> (Response.t * Body.t) Lwt.t

Respond with datas from file

Sourceval register : server -> (string * Route.route * endpoint) list -> server

Register a list of routes with the server

Sourceval register_route : server -> string -> Route.route -> endpoint -> server

Register a single route with the server

Sourceval register_route_string : server -> string -> string -> endpoint -> server

Register a single route, formatted as a string, with the server

Sourceval options : string -> endpoint -> server -> server

Register OPTIONS endpoint

Sourceval get : string -> endpoint -> server -> server

Register GET endpoint

Sourceval post : string -> endpoint -> server -> server

Register POST endpoint

Sourceval put : string -> endpoint -> server -> server

Register PUT endpoint

Sourceval update : string -> endpoint -> server -> server

Register UPDATE endpoint

Sourceval delete : string -> endpoint -> server -> server

Register delete endpoint

Sourceval static_file : string -> string -> server -> server

Regster endpoint that returns a single static file for all requests

Sourceval folder : string -> string -> server -> server

Reqister endpoint that will serve files from a firectory

Sourceval daemonize : ?directory:string -> ?syslog:bool -> server -> unit

Daemonize the server

Sourceexception Cannot_start_server
Sourceval start : server -> unit Lwt.t
Sourceval run : server -> unit
Sourceval (>|) : server -> (server -> server) -> server
Sourceval (>||) : server -> (server -> unit) -> server
OCaml

Innovation. Community. Security.