livery_static (livery v0.2.0)
View SourceStatic-directory file handler.
Returns a handler that serves files from a root directory, inferring
Content-Type from the extension, emitting a weak ETag for conditional
GET, honoring Range, and confining every path under the root so a
request can never traverse out of it.
Mount it on a router wildcard route and read the captured sub-path:
Router = livery_router:add(
'_', <<"/assets/*path">>, livery_static:handler("priv/assets"), #{}, Router0
).Without a router binding it falls back to stripping a configured
prefix from the request path. Options (all optional): binding
(default <<"path">>), prefix, index (default <<"index.html">>,
or false), cache_control (binary | directive list | undefined),
etag (default true), range (default true).
Security: the sub-path is percent-decoded and then confined - any ..
segment, control byte, or escape is rejected - and only regular files
are served (directories and symlinks yield 404).
Summary
Types
Functions
-spec handler(file:name_all()) -> livery_middleware:handler().
Static handler serving regular files under Root.
-spec handler(file:name_all(), opts()) -> livery_middleware:handler().
handler/1 with options.