Module
PuduLangDocgen.Serve
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
pathStr
Returns
Option[Str]
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
pathStr
Returns
Option[Str]
serve
fn serve(root: Str, host: Str, port: Int) -> Result[Int, Str]
Serves a folder until interrupted, answering how many requests were served.
Parameters
rootStrhostStrportInt
Returns
Result[Int, 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
rootStrlineStr
Returns
answer
The reply for a request path: the file, a folder's index, or the site's not-found page.
Parameters
rootStrpathStr
Returns
head
The response head of a reply.
Parameters
answered&Reply
Returns
Str