Module

PuduLangDocgen.Serve

View source

A local preview server for a published site folder

Types

Name Description
Reply A response: its status, media type, and body

Functions

Name Description
target The site-relative file a request path names: folders name their `index.html`, and paths that are not portable after percent-decoding name nothing.
decode A request path with `%XX` escapes decoded as UTF-8, or none when an escape is malformed.
serve Serves a folder until interrupted, answering how many requests were served.
reply The reply to a request line: files and folder indexes for `GET` and `HEAD`, the site's not-found page for missing files, and plain refusals for malformed or other requests. A `HEAD` reply keeps its body so the head reports its length; only the body is not sent.
answer The reply for a request path: the file, a folder's index, or the site's not-found page.
head The response head of a reply.

target

fn target(path: Str) -> Option[Str]

The site-relative file a request path names: folders name their index.html, and paths that are not portable after percent-decoding name nothing.

Parameters

path
Str

Returns

Option[Str]

View source

decode

fn decode(path: Str) -> Option[Str]

A request path with %XX escapes decoded as UTF-8, or none when an escape is malformed.

Parameters

path
Str

Returns

Option[Str]

View source

serve

fn serve(root: Str, host: Str, port: Int) -> Result[Int, Str]

Serves a folder until interrupted, answering how many requests were served.

Parameters

root
Str
host
Str
port
Int

Returns

Result[Int, Str]

View source

reply

fn reply(root: Str, line: Str) -> Reply

The reply to a request line: files and folder indexes for GET and HEAD, the site's not-found page for missing files, and plain refusals for malformed or other requests. A HEAD reply keeps its body so the head reports its length; only the body is not sent.

Parameters

root
Str
line
Str

Returns

Reply

View source

answer

fn answer(root: Str, path: Str) -> Reply

The reply for a request path: the file, a folder's index, or the site's not-found page.

Parameters

root
Str
path
Str

Returns

Reply

View source

fn head(answered: &Reply) -> Str

The response head of a reply.

Parameters

answered
&Reply

Returns

Str

View source