concept static resource in category scalatra

appears as: static resources, static resource, static resources
Scalatra in Action

This is an excerpt from Manning's book Scalatra in Action.

First we’ll discuss how to serve non-HTML files, such as text documents, web assets, and media files from a route. You’ll also learn how to serve static resources and how to apply gzip compression to HTTP responses.

6.1.2. Serving static resources

A web application often consists of static web assets, like images, CSS, and HTML. They’re usually located as static resources in the src/main/webapp source directory. Those resources can be served to a client in a generic way with the serveStatic-Resource method.

If no action can be found for a URL, Scalatra tries to serve a static resource by invoking serveStaticResource. If no resource can be found, a 404 response is returned with the previously set content type removed. This default behavior is implemented in the notFound handler:

notFound {
  contentType = null
  serveStaticResource() getOrElse halt(404, <h1>Not found.</h1>)
}

If an application requires nonstandard handling of static resources, you can overwrite the notFound handler.