Skip to content

Commit

Permalink
Format comments
Browse files Browse the repository at this point in the history
  • Loading branch information
tmattio committed Jun 1, 2020
1 parent 3e1fcf9 commit b43f9d6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 33 deletions.
8 changes: 4 additions & 4 deletions examples/static_serve_override.ml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
(* example showcasing a bug (or conflict) caused by the router interacting with
static middleware. Run this example and try:
(* example showcasing a bug (or conflict) caused by the router interacting with static
middleware. Run this example and try:
$ curl localhost:3000/examples/hello_world.ml
The result will be the corresponding file in ./examples/ rather than the
string "hello_world". *)
The result will be the corresponding file in ./examples/ rather than the string
"hello_world". *)

open Opium.Std

Expand Down
36 changes: 16 additions & 20 deletions opium/app.mli
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(** An opium app provides a set of convenience functions and types to construct
a rock 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
Expand All @@ -12,21 +12,19 @@ type t
(** A basic empty app *)
val empty : 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 *)
(** 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 *)
type builder = t -> t

val port : int -> builder
val ssl : cert:string -> key:string -> builder
val cmd_name : string -> builder

(** [not_found] accepts a regular Opium handler that will be used instead of the
default 404 handler. *)
(** [not_found] accepts a regular Opium handler that will be used instead of the default
404 handler. *)
val not_found : (Request.t -> (Httpaf.Headers.t * Opium_kernel.Body.t) Lwt.t) -> builder

(** A route is a function that returns a buidler that hooks up a handler to a
url mapping *)
(** A route is a function that returns a buidler that hooks up a handler to a url mapping *)
type route = string -> Handler.t -> builder

(** Method specific routes *)
Expand All @@ -46,8 +44,8 @@ val head : route
(** any [methods] will bind a route to any http method inside of [methods] *)
val any : Httpaf.Method.standard list -> 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. *)
(** 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

val action : Httpaf.Method.standard -> route
Expand All @@ -56,24 +54,22 @@ val middleware : Middleware.t -> builder
(** Convert an opium app to a rock app *)
val to_rock : t -> Opium_kernel.Rock.App.t

(** Start an opium server. The thread returned can be cancelled to shutdown the
server *)
(** Start an opium server. The thread returned can be cancelled to shutdown the server *)
val start : t -> Lwt_io.server Lwt.t

(** Create a cmdliner command from an app and run lwt's event loop *)
val run_command : t -> unit

(* Run a cmdliner command from an app. Does not launch Lwt's event loop. `Error
is returned if the command line arguments are incorrect. `Not_running is
returned if the command was completed without the server being launched *)
(* Run a cmdliner command from an app. Does not launch Lwt's event loop. `Error is
returned if the command line arguments are incorrect. `Not_running is returned if the
command was completed without the server being launched *)
val run_command' : t -> [> `Ok of unit Lwt.t | `Error | `Not_running ]
val json_of_body_exn : Request.t -> Yojson.Safe.t Lwt.t
val string_of_body_exn : Request.t -> string Lwt.t

(** Parse a request body encoded according to the
[application/x-www-form-urlencoded] content type (typically from POST
requests with form data) into an association list of key-value pairs. An
exception is raised on invalid data. *)
(** Parse a request body encoded according to the [application/x-www-form-urlencoded]
content type (typically from POST requests with form data) into an association list of
key-value pairs. An exception is raised on invalid data. *)
val urlencoded_pairs_of_body : Request.t -> (string * string list) list Lwt.t

val param : Request.t -> string -> string
Expand Down
16 changes: 7 additions & 9 deletions opium/static_serve.mli
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
(** Middleware serves all files (recursively) in the [local_path] directory
under the [uri_prefix] url. The responses contain a [Content-type] header
that is auto-detected based on the file extension using the
{!Magic_mime.lookup} function. Additional headers can be provided through
[headers].
(** Middleware serves all files (recursively) in the [local_path] directory under the
[uri_prefix] url. The responses contain a [Content-type] header that is auto-detected
based on the file extension using the {!Magic_mime.lookup} function. Additional
headers can be provided through [headers].
If [etag_of_fname] is provided, the response will contain an [ETag] header.
If the request contains an [If-None-Match] header with an [ETag] equal to
that generated by [etag_of_fname], this middleware will respond with
[304 Not Modified]. *)
If [etag_of_fname] is provided, the response will contain an [ETag] header. If the
request contains an [If-None-Match] header with an [ETag] equal to that generated by
[etag_of_fname], this middleware will respond with [304 Not Modified]. *)
val m
: local_path:string
-> uri_prefix:string
Expand Down

0 comments on commit b43f9d6

Please sign in to comment.