Static files
The {@link oajr.annotation.Rest#staticFiles @Rest(staticFiles)}
annotation is used to define paths and locations of statically-served files such as images or HTML
documents.
The value is a JSON map of paths to packages/directories located on either the classpath or working
directory.
package com.foo.mypackage;
@Rest(
path="/myresource",
staticFiles={"htdocs:docs"}
)
public class MyResource extends BasicRestServlet {...}
Static files are found by calling {@link java.lang.Class#getResource(String)} up the class hierarchy.
If not found, then an attempt is made to find the class in the Java working directory.
In the example above, given a GET request to /myresource/htdocs/foobar.html, the servlet will
attempt to find the foobar.html file in the following ordered locations:
- com.foo.mypackage.docs package.
- [working-dir]/docs directory.
-
Mappings are cumulative from parent to child.
Child resources can override mappings made on parent resources.
-
The media type on the response is determined by the
{@link oajr.RestContext#getMediaTypeForName(String)} method.
- {@link oajr.RestContext#REST_staticFiles}