Library
Module
Module type
Parameter
Class
Class type
Module type containing all file system dependent functions.
module IO : sig ... end
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, document is served as Mehari.app_octet_stream
.
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
.
Mime type of the served ressource is guessed by checking file name. Note that file names of the form *.gmi
will be served as text/gemini
.
show_hidden
decides whether hidden files should be listed. It defaults to false
for security reasons.