API Summary

What App provides

  • Routes: get, post, put, patch, delete, head, options, and path(prefix, group → …​) — patterns and matching order in Routing

  • Introspection: routes() reports every registered route as Route(method, path), in registration order

  • Filters: before(filter) / before(path, filter), same for after

  • Errors: exception(Type, handler), error(HttpStatus, handler), notFound(handler)

  • Rendering and assets: templates(renderer), staticFiles(classpathRoot), staticFiles(StaticFiles) — jte over classpath:/jte and classpath:/public at the root are the defaults, so neither has to be called; FreeMarkerTemplates, HandlebarsTemplates, and ThymeleafTemplates are TemplateRenderer implementations in modules of their own

  • Server: start() / start(port), stop(), join(), port(), server(factory)

What WebRequest provides

  • Request info: method(), path(), header(name), raw() for the servlet request itself

  • Path variables: pathParam, pathParamLong, pathParamEnum

  • Parameters: param (400 when missing), paramLong, paramEnum, each with a (…​, default) form for optional parameters; paramBoolean(name, default); params(name) for repeated values

  • Query vs. form: queryParam, queryParams, formParam, formParams

  • Cookies the client sent: cookie(name), cookies()

  • Body: body(), bodyJson(), bodyJson(reader) (400 on a body the reader rejects), multipart upload via file(name)

  • Session: sessionAttr(key) / sessionAttr(key, value) / removeSessionAttr

  • Flash: flash(key, value), read exactly once with flashed(key) on the request after a redirect

  • Errors: errorMessage() inside an error(status, handler) handler

What WebResponse provides

  • Bodies: html, text, json(raw), json(JsonValue), json(value, writer), bytes, template(name), template(name, model), stream(contentType, out → …​), sse(stream → …​), raw((req, res) → …​)

  • Statuses: empty(), empty(HttpStatus), noContent(), redirect(location), redirect(location, HttpStatus)

  • Building on: status, header, contentType, attachment, body, cookie(name, value), cookie(name, value, maxAge), cookie(Cookie), removeCookie

  • Reading back: status(), header(name), headers(), cookies(), body()

See The Response for the shape of body() and the lambda families.