package simple_httpd

  1. Overview
  2. Docs

Module Dir.Embedded_fsSource

An embedded file system, as a list of files with (relative) paths. This is useful in combination with the "simple-httpd-mkfs" tool, which embeds the files it's given into a OCaml module.

Sourcetype t

The pseudo-filesystem

Sourceval create : ?mtime:float -> unit -> t

create a new pseudo file system.

Sourceval add_file : t -> path:string -> ?mtime:float -> ?headers:Headers.t -> string -> unit

add_file ~path content add at path with the given content to the virtual file system.

  • raises Invalid_argument

    if the path contains '..' or if it tries to make a directory out of an existing path that is a file.

  • parameter path:

    the name of the file (in the url)

  • parameter mtime:

    that last modification time, used for caching.

  • parameter headers:

    extra headers, like mime type.

Sourceval add_dynamic : t -> path:string -> ?mtime:float -> ?headers:Headers.t -> dynamic -> unit

Add some dynamic content to the virtual file system.

  • parameter path:

    the name of the file (in the url)

  • parameter mtime:

    that last modification time, used for caching.

  • parameter headers:

    extra headers, like mime type.

Sourceval add_path : t -> path:string -> ?mtime:float -> ?headers:Headers.t -> ?deflate:string -> string -> unit

add_path vfs ~path real_path add a path to a file on disk at real_path in the embedded file system

  • parameter deflate:

    a path on the disk to a compressed version of the file with Camlzip.

  • parameter path:

    the name of the file (in the url)

  • parameter mtime:

    that last modification time, used for caching.

  • parameter headers:

    extra headers, like mime type.

Sourceval to_vfs : t -> (module VFS)

Convert a pseudo file system into a vfs to use with Dir.add_vfs.