Jetty Extras

Serving Resources from a relative path

Sometimes you may want to serve resources from a relative path, for example a sibling directory located at ../client. But paths containing .. are considered aliased and Jetty disallows these by default, as described in this policy.

If you’ve evaluated the security risks described in the link above and wish to enable aliases in paths, you can do so with allowAliases(true), eg:

import unfiltered.jetty.ContextAdder

unfiltered.jetty.Server.http(8080).
  context("/client"){ ctx: ContextAdder =>
    ctx.resources(new java.net.URL(
      """file:../client"""
    )).allowAliases(true)
  }.plan(myPlan).run()

Enabling Request Logs

Jetty can be configured to log all requests in Common or Extended formats with requestLogging. This is a global, not per-context, setting. At minimum you need to specify where to log to:

unfiltered.jetty.Server.http(8080).plan(myPlan).requestLogging("/tmp/access.log").run()
The source code for this page can be found here.