mirror of
https://github.com/c-cube/tiny_httpd.git
synced 2025-12-06 11:15:35 -05:00
more doc
This commit is contained in:
parent
5735f813a5
commit
e225212dba
1 changed files with 33 additions and 9 deletions
|
|
@ -1,22 +1,45 @@
|
||||||
|
|
||||||
(** behavior of static directory *)
|
(** Serving static content from directories
|
||||||
|
|
||||||
|
This module provides the same functionality as the "http_of_dir" tool.
|
||||||
|
It exposes a directory (and its subdirectories), with the optional ability
|
||||||
|
to delete or upload files.
|
||||||
|
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
|
(** behavior of static directory.
|
||||||
|
|
||||||
|
This controls what happens when the user requests the path to
|
||||||
|
a directory rather than a file. *)
|
||||||
type dir_behavior =
|
type dir_behavior =
|
||||||
| Index
|
| Index
|
||||||
(** Redirect to index.html if present *)
|
(** Redirect to index.html if present, else fails. *)
|
||||||
| Lists
|
| Lists
|
||||||
(** Lists content of directory *)
|
(** Lists content of directory. Be careful of security implications. *)
|
||||||
| Index_or_lists
|
| Index_or_lists
|
||||||
(** Redirect to index.html if present and Lists content otherwise *)
|
(** Redirect to index.html if present and lists content otherwise.
|
||||||
|
This is useful for tilde ("~") directories and other per-user behavior,
|
||||||
|
but be mindful of security implications *)
|
||||||
| Forbidden
|
| Forbidden
|
||||||
(** Forbid access to directory *)
|
(** Forbid access to directory. This is suited for serving assets, for example. *)
|
||||||
|
|
||||||
(** configuration for static file handlers *)
|
(** configuration for static file handlers *)
|
||||||
type config = {
|
type config = {
|
||||||
mutable download: bool;
|
mutable download: bool;
|
||||||
|
(** Is downloading files allowed? *)
|
||||||
|
|
||||||
mutable dir_behavior: dir_behavior;
|
mutable dir_behavior: dir_behavior;
|
||||||
|
(** Behavior when serving a directory and not a file *)
|
||||||
|
|
||||||
mutable delete: bool;
|
mutable delete: bool;
|
||||||
|
(** Is deleting a file allowed? (with method DELETE) *)
|
||||||
|
|
||||||
mutable upload: bool;
|
mutable upload: bool;
|
||||||
|
(** Is uploading a file allowed? (with method PUT) *)
|
||||||
|
|
||||||
mutable max_upload_size: int;
|
mutable max_upload_size: int;
|
||||||
|
(** If {!upload} is true, this is the maximum size in bytes for
|
||||||
|
uploaded files. *)
|
||||||
}
|
}
|
||||||
|
|
||||||
(** default configuration: [
|
(** default configuration: [
|
||||||
|
|
@ -31,7 +54,8 @@ val default_config : unit -> config
|
||||||
(** [add_dirpath ~config ~dir ~prefix server] adds route handle to the
|
(** [add_dirpath ~config ~dir ~prefix server] adds route handle to the
|
||||||
[server] to serve static files in [dir] when url starts with [prefix],
|
[server] to serve static files in [dir] when url starts with [prefix],
|
||||||
using the given configuration [config]. *)
|
using the given configuration [config]. *)
|
||||||
val add_dir_path : config:config ->
|
val add_dir_path :
|
||||||
|
config:config ->
|
||||||
dir:string ->
|
dir:string ->
|
||||||
prefix:string ->
|
prefix:string ->
|
||||||
Tiny_httpd.t -> unit
|
Tiny_httpd.t -> unit
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue