Module Webs_cli

Command line interface support.

Options

val listener : ?opts:string list -> ?docs:string -> ?default_port:int -> ?default_listener:Webs_unix.listener -> unit -> Webs_unix.listener Cmdliner.Term.t

listener is an option for specifying a connection listener.

  • default_port is the default port when unspecified (defaults to 8000).
  • default_listen is the default listener when unspecified (defaults to `Host ("localhost", default_port)).
  • docs is the section where the option is documented.
  • opts are the options to use (defaults to ["l";"listen"]).
val service_path : ?opts:string list -> ?docs:string -> unit -> Webs.Http.path option Cmdliner.Term.t

service_path is an option for specifying an optional service path.

val docroot : ?opts:string list -> ?docs:string -> unit -> string option Cmdliner.Term.t

docroot is an option for specifying an optional document root.

  • docs is the section where the option is documented.
  • opts are the options to use (defaults to ["d";"docroot"]).
val max_connections : ?opts:string list -> ?docs:string -> unit -> int Cmdliner.Term.t

max_connections is an option for specifying the maximal amount of concurrent connections served. Defaults to Webs_httpc.default_max_connections.

  • docs is the section where the option is documented.
  • opts are the options to use (defaults to ["m";"max-connections"])

Quick service setup

val conf_docroot : unit -> (string, string) Stdlib.result Cmdliner.Term.t

conf_docroot () requires a docroot option, realpathes is and logs it.

val quick_serve : ?version:string -> ?man:Cmdliner.Manpage.block list -> ?doc:string -> name:string -> (Webs.Http.req -> Webs.Http.resp) -> unit

quick_serve ~name (Ok s) runs s with the Webs_httpc and handles a few default command line options. If you want to be able to specify a docroot on the command line you need to specify with_docroot:true. There is no default for docroots it always needs to be specified explicitely.

val quick_serve' : ?version:string -> ?man:Cmdliner.Manpage.block list -> ?doc:string -> name:string -> conf:('a, string) Stdlib.result Cmdliner.Term.t -> ('a -> Webs.Http.req -> Webs.Http.resp) -> unit

quick_serve' is like quick_serve but additional configuration parameters can be parsed from the command line and be checked before installing the service.