Class StaticFilesResource
java.lang.Object
org.apache.juneau.rest.server.servlet.RestResource
org.apache.juneau.rest.server.staticfile.StaticFilesResource
Child-resource flavor of the static-files capability.
Mounts as a routed child via @Rest(children=StaticFilesResource.class)
under a parent at the subtree /static and serves static files by delegating to the
flavor-neutral StaticFiles worker bean resolved from the request context
(RestContext.getStaticFiles()) — the same worker the mixin and
servlet flavors use, so the three forms cannot drift.
Whereas the StaticFilesMixin mixin pins its op at /static/* to merge into a host's
namespace, this child declares the subtree at the class level (@Rest(path="/static"))
and pins the ops at /* — the op must not re-pin /static/* or it would
double-path to /static/static/* under the routed-subtree wiring.
See Also:
- Since:
- 10.0.0
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.juneau.rest.server.servlet.RestResource
RestResource.Builder<R extends RestResource,SELF extends RestResource.Builder<R, SELF>>, RestResource.DefaultBuilder<R extends RestResource> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetStaticFile(RestRequest req, String path, Locale locale) [GET /*] — serve a static file from the activeStaticFilesworker bean.headStaticFile(RestRequest req, String path, Locale locale) [HEAD /*] — return GET headers for a static file without the body.Methods inherited from class org.apache.juneau.rest.server.servlet.RestResource
builder, doLog, getContext, getPaths, getRequest, getResponse, getRestBuilder, log, log, setContext
-
Constructor Details
-
StaticFilesResource
public StaticFilesResource()
-
-
Method Details
-
getStaticFile
[GET /*] — serve a static file from the activeStaticFilesworker bean.- Parameters:
req- The current REST request — suppliesRestContext.getStaticFiles().path- The trailing remainder after the mount prefix.locale- The request locale (used for localized resource lookups).- Returns:
- The matching
HttpResource(with content type + cache headers). - Throws:
NotFound- If no resource matches the requested path.
-
headStaticFile
[HEAD /*] — return GET headers for a static file without the body.- Parameters:
req- The current REST request — suppliesRestContext.getStaticFiles().path- The trailing remainder after the mount prefix.locale- The request locale (used for localized resource lookups).- Returns:
- The matching
HttpResource(with headers; body suppressed by the processor). - Throws:
NotFound- If no resource matches the requested path.
-