Assets

io.eezo.http.Assets
object Assets

The application's assets: the files it ships in its jar under assets/ and serves as they are, under /assets/, with a version in every address computed from the file's bytes.

The stylesheet the sbt plugin builds from tailwind.css is one, at assets/tailwind.css; a file written by hand under src/main/resources/assets is another, and both are served the same way. A layout links one through url, which spells the version in, so a browser may keep the file for a year and the next deploy, whose bytes differ, is a new address. The route is one of HttpApp.frameworkRoutes, appended after the application's table, so an application that mounts its own catch all under /assets keeps winning.

The version is per file rather than one digest over a list, so that no list has to be kept: a file the build writes and a file nobody told this object about get the same treatment. Each digest is computed once per process. A process's jar never changes, and under the dev loop every restart is a new process.

What is refused: a path that is not a plain descent into assets/ (an empty segment, . or ..), a file that is not there, and a file whose extension names no content type below. All three are the same 404 to the client, because none of them is the client's to tell apart.

Attributes

Source
Assets.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Assets.type

Members list

Value members

Concrete methods

def contentType(name: String): Option[String]

The content type for a file name, and nothing for an extension eezo does not serve.

The content type for a file name, and nothing for an extension eezo does not serve.

Attributes

Source
Assets.scala
def read(path: String): Option[Array[Byte]]

The file's bytes, or nothing: for a path that is not a plain descent into assets/, and for a file that is not there.

The file's bytes, or nothing: for a path that is not a plain descent into assets/, and for a file that is not there.

Attributes

Source
Assets.scala
def url(name: String): Url

The address a page links an asset under: /assets/?v=. Absolute, because the route is appended at the root and no mount moves it.

The address a page links an asset under: /assets/?v=. Absolute, because the route is appended at the root and no mount moves it.

A file that is not there is a defect, not an empty link: the page that asked was built expecting the file, and a stylesheet that silently fails to load is harder to find than the name in this message.

Attributes

Source
Assets.scala
def version(name: String): Option[String]

The version of one file: the first twelve hex characters of its SHA-256, or nothing when the file is not there. Remembered per file after the first ask.

The version of one file: the first twelve hex characters of its SHA-256, or nothing when the file is not there. Remembered per file after the first ask.

Attributes

Source
Assets.scala

Concrete fields

val Prefix: String

Attributes

Source
Assets.scala