std1.0.0-beta-7 SafeC docs

std :: http::static_files

Function std::http_serve_dir

#include <std/http/static_files.h> source ยท definition

struct HttpResponse http_serve_dir(
    const &HttpRequest req,
    const &char root,
    const &char url_path,
    const ?&StaticOptions opts,
)

Serves 'url_path' (percent-encoded, as in the request; a query string is ignored) from under the directory 'root'. 403 for a path that tries to leave the root ("..", a backslash, a NUL byte); a directory without a trailing '/' is redirected (301) to one so relative links resolve.