No matching definitions.

tourist/static

src/tourist/static.tur

static file serving with path-traversal guard.

Since: v0.1.0

defn

serve-static!

(serve-static! [url-prefix : cstr fs-root : cstr] :)

declare a static-file serving route.

url-prefixURL path prefix to strip, e.g. "/assets"
fs-rootfilesystem directory to serve from, e.g. "./public"

:int -- static Route handle; consumed by tourist

(serve-static! "/assets" "./public")

Since: v0.1.0

defn

static-item?

(static-item? [item : int] :)

true if an item handle is a static-file route.

item:int item handle from serve-static! or any other DSL constructor

:bool

Since: v0.1.0

defn

static-route-fs-root

(static-route-fs-root [route : int] :)

filesystem root directory of a static route.

route:int static route handle from serve-static!

:cstr -- absolute or relative path to the served directory

Since: v0.1.0

defn

static-serve

(static-serve [fs-root : cstr rel-raw : int] :)

serve a file from fs-root; returns 0 on any miss.

fs-root:cstr filesystem root directory
rel-raw:int relative path as char* cast to int64_t (from wildcard
capture); 0 is treated as a miss

:int -- Response handle (200 + body) on success, 0 on miss

Since: v0.1.0

Internal definitions
__static-pat-join-- build "<prefix>/*" by concatenating two cstrs.
__static-route-alloc-- allocate a __tourist_static_route struct.