This algebra provides vocabulary to define endpoints serving static assets.
"org.julienrf" %% "endpoints-algebra" % "0.15.0"
The module enriches the
Endpoints algebra with new constructors for endpoints and path segments. It also introduces the concepts of
AssetPath. The typical usage looks like the following:
val assets: Endpoint[AssetRequest, AssetResponse] = assetsEndpoint(path / "assets" / assetSegments())
assetsSegments method defines a path containing (possibly) multiple segments.
The concrete instantiation of the
AssetResponse types is left to interpreters. Typically,
AssetResponse is mapped to binary data. Interpreters also have to provide a constructor for
AssetRequest, so that the endpoint can be called. Typically, such constructors take the path of the asset as a
Server interpreters are encouraged to leverage caching HTTP headers such as
Cache-Control, and gzip content encoding. Incidentally, the algebra provides an abstract
digest: Map[String, String] member to be overridden by users with digests uniquely identifying the assets:
The content of the digests can be included to the asset segments so that servers know that the requested version of the asset matches the one it uses, enabling servers to indefinitely cache the asset.