Class WebJarsMixin

java.lang.Object
org.apache.juneau.rest.server.staticfile.WebJarsMixin

public class WebJarsMixin extends Object
Mixin that serves WebJar files from the classpath at /webjars/*.

Compose it into the resource that renders console pages, next to DataTablesMixin: @Rest(mixins={FreemarkerMixin.class, ViewsMixin.class, DataTablesMixin.class, WebJarsMixin.class}). The console toolkit packs (jquery, datatables, datatables-buttons) resolve their URLs through WebJarResolver to this mount; a host that doesn't mount it renders the page, but those URLs 404.

Only files under META-INF/resources/webjars/ are served, and only with a known extension (js, css, map, woff2, woff, ttf, svg, png). The remainder path is checked as delivered and again after one round of percent-decoding, and is never normalized: a . or .. segment, an empty segment, a leading /, a backslash or an encoded separator returns 404, as does a directory or a missing file. Responses carry Cache-Control: public, max-age=31536000, immutable; the URLs are cache-busted by WebJarResolver.

Mixin-only deployment:

The mount path is pinned at the op level by @RestGet(path="/webjars/*"); a class-level @Rest(paths=...) would be ignored under the mixin pattern.

Since:
10.0.0
  • Field Details

  • Constructor Details

  • Method Details

    • getWebJarFile

      [GET /webjars/*] — serve one WebJar file.
      Parameters:
      req - The current request.
      Returns:
      The file.
      Throws:
      NotFound - If the path fails a check, has an unknown extension, or names no file.
    • headWebJarFile

      [HEAD /webjars/*] — the GET headers without the body (the response processor drops the body).
      Parameters:
      req - The current request.
      Returns:
      The file.
      Throws:
      NotFound - If the path fails a check, has an unknown extension, or names no file.