package tiny_httpd
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=21af1a39fdc4b139eb56d6f7b8c39863
sha512=07b17c0fdb3ab49e856fe248a0db7d1be974d900822c1b4d28758751ba096c86f24dc72b024ab272c1720370e640ea66f1cab4937b19c47ff66bda7b876ba781
doc/tiny_httpd/Tiny_httpd_dir/index.html
Module Tiny_httpd_dirSource
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.
type dir_behavior = | Index(*Redirect to index.html if present, else fails.
*)| Lists(*Lists content of directory. Be careful of security implications.
*)| Index_or_lists(*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(*Forbid access to directory. This is suited for serving assets, for example.
*)
behavior of static directory.
This controls what happens when the user requests the path to a directory rather than a file.
type config = {mutable download : bool;(*Is downloading files allowed?
*)mutable dir_behavior : dir_behavior;(*Behavior when serving a directory and not a file
*)mutable delete : bool;(*Is deleting a file allowed? (with method DELETE)
*)mutable upload : bool;(*Is uploading a file allowed? (with method PUT)
*)mutable max_upload_size : int;
}configuration for static file handlers
default configuration: { download=true ; dir_behavior=Forbidden ; delete=false ; upload=false ; max_upload_size = 10 * 1024 * 1024 }
add_dirpath ~config ~dir ~prefix server adds route handle to the server to serve static files in dir when url starts with prefix, using the given configuration config.