package mehari

  1. Overview
  2. Docs

Module type containing all UNIX-dependent functions.

module IO : sig ... end
type addr
type handler = addr request -> response IO.t
type dir_path

Static files

val response_document : ?mime:mime -> dir_path -> response IO.t

Same as Mehari.response but respond with content of given filename and use given Mehari.mime as mime type. If filename is not present on filesystem, responds with Mehari.not_found. If mime parameter is not supplied, use Mehari.no_mime as mime type.

val static : ?handler:(dir_path -> handler) -> ?dir_listing: (([ `Regular_file | `Directory | `Other ] * string) list -> handler) -> ?index:string -> ?show_hidden:bool -> dir_path -> handler

static dir validates the path parameter (retrieved by calling Mehari.param req 1) by checking that it is relative and does not contain parent directory references. If these checks fail, responds with Mehari.not_found.

If the checks succeed, static calls handler path request, where path is the path generated by the concatenation of directory that was passed to static and path of request. handler defaults to response_document.

If a directory is requested, static will look for a file named index in that directory to return. Otherwise, a directory file listing will be generated by calling dir_listing [ filename; ... ] request. index is default on index.gmi.

show_hidden decides whether hidden files should be listed. It defaults to false for security reasons.

OCaml

Innovation. Community. Security.