package mehari
Install
Dune Dependency
Authors
Maintainers
Sources
md5=bc6261e277d3d6141970027e9d1d3f26
sha512=5ceb0c1e492effe67dc0e659f2837ec2f962feb9dd7f92562a9f594f1dd623e0483a006ae16371deb1368f993a5996623c2e9f56113c1f91fca526899cfc2eae
doc/mehari/Mehari/index.html
Module Mehari
Source
This module provides the core abstraction, it does not depend on any platform code, and does not interact with the environment.
Types
Gemtext
Implementation of the Gemini own native response format. Note that if a string containing line breaks (CR
or CRLF
) is given to functions heading
, list_item
and quote
only the first line will be formatted and the others treated as normal text. To avoid this behavior, see Mehari.paragraph
.
paragraph to_gemtext str
is a convenient function to transform a string containing line breaks (CR
or CRLF
) into a Gemtext document.
open Mehari.Gemtext
let () = assert (Mehari.paragraph quote "hello\nworld" = [ quote "hello"; quote "world" ])
Request
User client certificates.
Response
Creates a new response
with given Mehari.status
.
Status
A wrapper around Gemini status codes.
code_of_status s
is status code associated with status s
.
Body
A note on data stream response
Mehari offers ways to keep client connections open forever and stream data in real time such as seq
and stream
functions when the flush
parameter is specified. It is important to note that most Gemini clients do not support streaming and should be used with caution. That's why this parameter is set to false
by default in all the functions that Mehari expose.
Creates a body
from given lines. Each line is written followed by a newline (LF
) character.
page ~title content
creates a simple Gemtext body
of form:
# title
content
Creates a body
from a string sequence. See A note on data stream response for a description of flush
parameter.
stream (fun consume -> ...)
creates a body
from a data stream. Each call to consume
write the given input on socket. Useful for stream data or file chunk in real time. See A note on data stream response for a description of flush
parameter.
Mime
make_mime ?charset mime
creates a mime
type from given charset
. Charset defaults to utf-8
if mime type begins with text/
.
from_filename ?charset fname
tries to create a mime
by performing a mime lookup based on file extension of fname
.
Note that mime gemini
are not infered from files with .gmi
extension. See https://github.com/Psi-Prod/Mehari/issues/36.
from_content ?charset ~tree c
tries to create a mime
type by performing a mime lookup based on content c
. tree
is the tree used to build the MIME database.
gemini ?charset ?lang ()
is text/gemini; charset=...; lang=...
.