package tiny_httpd
Install
    
    dune-project
 Dependency
Authors
Maintainers
Sources
sha256=ef806444b2f9e53d10976b9124902560d0855124433537080e6d0bec48d202e5
    
    
  sha512=539530eb9e511b6ed4d69bb083f421d5f51b183c347c116a52f24210f30b1c9b14a029e2b82d6e0d698c74ab75ba5c307a1976711558a1419df287335b2a8f51
    
    
  doc/tiny_httpd.unix/Tiny_httpd_unix/Dir/index.html
Module Tiny_httpd_unix.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 used to prevent users from building a config directly. Use default_config or config instead.
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;
- _rest : hidden;(*- Just ignore this field. *)
}configuration for static file handlers. This might get more fields over time.
default configuration:  { download=true ; dir_behavior=Forbidden ; delete=false ; upload=false ; max_upload_size = 10 * 1024 * 1024 }
val config : 
  ?download:bool ->
  ?dir_behavior:dir_behavior ->
  ?delete:bool ->
  ?upload:bool ->
  ?max_upload_size:int ->
  unit ->
  configBuild a config from default_config.
val add_dir_path : 
  config:config ->
  dir:string ->
  prefix:string ->
  Tiny_httpd_core.Server.t ->
  unitadd_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.
vfs_of_dir dir makes a virtual file system that reads from the disk.
val add_vfs : 
  config:config ->
  vfs:(module VFS) ->
  prefix:string ->
  Tiny_httpd_core.Server.t ->
  unitSimilar to add_dir_path but using a virtual file system instead.
An embedded file system, as a list of files with (relative) paths. This is useful in combination with the "tiny-httpd-mkfs" tool, which embeds the files it's given into a OCaml module.