Adds support for mapping and inferring formats to content types.
$ - Provides a request-scoped format variable $ - Maps formats to content types and vice versa $ - Augments the content-type inferrer to use the format
Attributes
- Companion
- object
- Graph
-
- Supertypes
-
trait ScalatraBasetrait TypeConverterSupporttrait ScalatraParamsImplicitstrait Initializabletrait DynamicScopetrait RequestResponseScopetrait CoreDsltrait Controltrait Handlertrait ScalatraContexttrait CookieContexttrait SessionSupporttrait ServletApiImplicitsclass Objecttrait Matchableclass AnyShow all
Members list
Type members
Inherited classlikes
Attributes
- Inherited from:
- Initializable
- Supertypes
-
class Objecttrait Matchableclass Any
Inherited types
Attributes
- Inherited from:
- Initializable
Value members
Concrete methods
The list of media types accepted by the current request. Parsed from the Accept
header.
The list of media types accepted by the current request. Parsed from the Accept
header.
Attributes
A list of formats accepted by default.
A list of formats accepted by default.
Attributes
The default format.
The default format.
Attributes
Returns the request-scoped format. If not explicitly set, the format is: $ - the format
request parameter, if present in formatParams
$ - the first match from Accept
header, looked up in mimeTypes
$ - the format from the Content-Type
header, as looked up in mimeTypes
$ - the default format
Returns the request-scoped format. If not explicitly set, the format is: $ - the format
request parameter, if present in formatParams
$ - the first match from Accept
header, looked up in mimeTypes
$ - the format from the Content-Type
header, as looked up in mimeTypes
$ - the default format
Attributes
Inherited methods
Adds a filter to run after the route. The filter only runs if each routeMatcher returns Some. If the routeMatchers list is empty, the filter runs for all routes.
Adds a filter to run after the route. The filter only runs if each routeMatcher returns Some. If the routeMatchers list is empty, the filter runs for all routes.
Attributes
- Inherited from:
- ScalatraBase
Adds a filter to run before the route. The filter only runs if each routeMatcher returns Some. If the routeMatchers list is empty, the filter runs for all routes.
Adds a filter to run before the route. The filter only runs if each routeMatcher returns Some. If the routeMatchers list is empty, the filter runs for all routes.
Attributes
- Inherited from:
- ScalatraBase
Gets the content type of the current response.
Sets the content type of the current response.
Attributes
- Inherited from:
- CookieContext
Attributes
- See also
-
get
- Inherited from:
- ScalatraBase
Attributes
- Inherited from:
- ScalatraBase
Defines an error handler for exceptions thrown in either the before block or a route action.
Defines an error handler for exceptions thrown in either the before block or a route action.
If the error handler does not match, the result falls through to the previously defined error handler. The default error handler simply rethrows the exception.
The error handler is run before the after filters, and the result is rendered like a standard response. It is the error handler's responsibility to set any appropriate status code.
Attributes
- Inherited from:
- ScalatraBase
Explicitly sets the request-scoped format. This takes precedence over whatever was inferred from the request.
Explicitly sets the request-scoped format. This takes precedence over whatever was inferred from the request.
Attributes
- Inherited from:
- ScalatraContext
Explicitly sets the request-scoped format. This takes precedence over whatever was inferred from the request.
Explicitly sets the request-scoped format. This takes precedence over whatever was inferred from the request.
Attributes
- Inherited from:
- ScalatraContext
Builds a full URL from the given relative path. Takes into account the port configuration, https, ...
Builds a full URL from the given relative path. Takes into account the port configuration, https, ...
Value parameters
- path
-
a relative path
Attributes
- Returns
-
the full URL
- Inherited from:
- ScalatraBase
The Scalatra DSL core methods take a list of org.scalatra.RouteMatcher and a block as the action body. The return value of the block is rendered through the pipeline and sent to the client as the response body.
The Scalatra DSL core methods take a list of org.scalatra.RouteMatcher and a block as the action body. The return value of the block is rendered through the pipeline and sent to the client as the response body.
See org.scalatra.ScalatraBase#renderResponseBody for the detailed behaviour and how to handle your response body more explicitly, and see how different return types are handled.
The block is executed in the context of a CoreDsl instance, so all the methods defined in this trait are also available inside the block.
get("/") {
<form action="/echo">
<label>Enter your name</label>
<input type="text" name="name"/>
</form>
}
post("/echo") {
"hello {params('name)}!"
}
ScalatraKernel provides implicit transformation from boolean blocks, strings and regular expressions to org.scalatra.RouteMatcher, so you can write code naturally.
get("/", request.getRemoteHost == "127.0.0.1") { "Hello localhost!" }
Attributes
- Inherited from:
- ScalatraBase
Attributes
- Inherited from:
- Control
Immediately halts processing of a request. Can be called from either a before filter or a route.
Immediately halts processing of a request. Can be called from either a before filter or a route.
Value parameters
- body
-
a result to render through the render pipeline as the body
- headers
-
headers to add to the response
- status
-
the status to set on the response, or null to leave the status unchanged.
Attributes
- Inherited from:
- Control
Handles a request and renders a response.
Handles a request and renders a response.
$ 1. If the request lacks a character encoding, defaultCharacterEncoding
is set to the request.
$ 2. Sets the response's character encoding to defaultCharacterEncoding
.
$ 3. Binds the current request
, response
, and multiParams
, and calls executeRoutes()
.
Attributes
- Definition Classes
-
ScalatraBase -> Handler
- Inherited from:
- ScalatraBase
Attributes
- See also
-
head
- Inherited from:
- ScalatraBase
Gets an init parameter from the config.
Gets an init parameter from the config.
Value parameters
- name
-
the name of the key
Attributes
- Returns
-
an option containing the value of the parameter if defined, or
None
if the parameter is not set. - Inherited from:
- ScalatraBase
Initializes the kernel. Used to provide context that is unavailable when the instance is constructed, for example the servlet lifecycle. Should set the config
variable to the parameter.
Initializes the kernel. Used to provide context that is unavailable when the instance is constructed, for example the servlet lifecycle. Should set the config
variable to the parameter.
Value parameters
- config
-
the configuration.
Attributes
- Inherited from:
- ScalatraBase
A boolean flag representing whether the kernel is in development mode. The default is true if the environment
begins with "dev", case-insensitive.
A boolean flag representing whether the kernel is in development mode. The default is true if the environment
begins with "dev", case-insensitive.
Attributes
- Inherited from:
- ScalatraBase
Defines a block to run if matching routes are found only for other methods. The set of matching methods is passed to the block.
Defines a block to run if matching routes are found only for other methods. The set of matching methods is passed to the block.
Attributes
- Inherited from:
- ScalatraBase
The current multiparams. Multiparams are a result of merging the standard request params (query string or post params) with the route parameters extracted from the route matchers of the current route. The default value for an unknown param is the empty sequence. Invalid outside handle
.
The current multiparams. Multiparams are a result of merging the standard request params (query string or post params) with the route parameters extracted from the route matchers of the current route. The default value for an unknown param is the empty sequence. Invalid outside handle
.
Attributes
- Inherited from:
- ScalatraBase
Attributes
- Inherited from:
- ScalatraBase
Defines a block to run if no matching routes are found, or if all matching routes pass.
Defines a block to run if no matching routes are found, or if all matching routes pass.
Attributes
- Inherited from:
- ScalatraBase
Attributes
- See also
-
get
- Inherited from:
- ScalatraBase
Attributes
- Inherited from:
- ScalatraBase
Attributes
- Inherited from:
- ScalatraBase
Immediately exits from the current route.
Attributes
- See also
-
patch
- Inherited from:
- ScalatraBase
Attributes
- See also
-
get
- Inherited from:
- ScalatraBase
Attributes
- See also
-
get
- Inherited from:
- ScalatraBase
Sends a redirect response and immediately halts the current action.
Sends a redirect response and immediately halts the current action.
Attributes
- Inherited from:
- ScalatraBase
Attributes
- Inherited from:
- ScalatraBase
The effective path against which routes are matched. The definition varies between servlets and filters.
The effective path against which routes are matched. The definition varies between servlets and filters.
Attributes
- Inherited from:
- ScalatraBase
Attributes
- Inherited from:
- ScalatraBase
Attributes
- Inherited from:
- ScalatraBase
The servlet context in which this kernel runs.
Attributes
- Inherited from:
- SessionSupport
The current session. If none exists, None is returned.
A hook to shutdown the class. Bridges the gap between servlet's destroy and filter's destroy.
A hook to shutdown the class. Bridges the gap between servlet's destroy and filter's destroy.
Attributes
- Inherited from:
- Initializable
Gets the status code of the current response.
Sets the status code of the current response.
Attributes
- Inherited from:
- DefaultImplicitConversions
Attributes
- Inherited from:
- DefaultImplicitConversions
Attributes
- Inherited from:
- DefaultImplicitConversions
Error handler for HTTP response status code range. You can intercept every response code previously specified with #status or even generic 404 error.
Error handler for HTTP response status code range. You can intercept every response code previously specified with #status or even generic 404 error.
trap(403) {
"You are not authorized"
}
}*
}}
Attributes
- Inherited from:
- ScalatraBase
Returns a context-relative, session-aware URL for a path and specified parameters. Finally, the result is run through response.encodeURL
for a session ID, if necessary.
Returns a context-relative, session-aware URL for a path and specified parameters. Finally, the result is run through response.encodeURL
for a session ID, if necessary.
Value parameters
- params
-
params, to be appended in the form of a query string
- path
-
the base path. If a path begins with '/', then the context path will be prepended to the result
Attributes
- Returns
-
the path plus the query string, if any. The path is run through
response.encodeURL
to add any necessary session tracking parameters. - Inherited from:
- ScalatraBase
Executes the block with the given request bound to the request
method.
Executes the block with the given request bound to the request
method.
Attributes
- Inherited from:
- DynamicScope
Executes the block with the given response bound to the response
method.
Executes the block with the given response bound to the response
method.
Attributes
- Inherited from:
- DynamicScope
Concrete fields
A map of suffixes to content types.
A map of suffixes to content types.
Attributes
A map of content types to suffixes. Not strictly a reverse of formats
.
A map of content types to suffixes. Not strictly a reverse of formats
.
Attributes
Inherited fields
The configuration, typically a ServletConfig or FilterConfig.
The configuration, typically a ServletConfig or FilterConfig.
Attributes
- Inherited from:
- ScalatraBase
The routes registered in this kernel.
Implicits
Inherited implicits
Attributes
- Inherited from:
- LowPriorityImplicitConversions
Attributes
- Inherited from:
- LowPriorityImplicitConversions
Attributes
- Inherited from:
- LowPriorityImplicitConversions
Attributes
- Inherited from:
- LowPriorityImplicitConversions
Attributes
- Inherited from:
- LowPriorityImplicitConversions
Attributes
- Inherited from:
- LowPriorityImplicitConversions
Attributes
- Inherited from:
- LowPriorityImplicitConversions
Attributes
- Inherited from:
- LowPriorityImplicitConversions
Attributes
- Inherited from:
- Initializable
Attributes
- Inherited from:
- CookieContext
Attributes
- Inherited from:
- DefaultImplicitConversions
Attributes
- Inherited from:
- ServletApiImplicits
Attributes
- Inherited from:
- ServletApiImplicits
Attributes
- Inherited from:
- ServletApiImplicits
Attributes
- Inherited from:
- ServletApiImplicits
Attributes
- Inherited from:
- LowestPriorityImplicitConversions
The currently scoped request. Valid only inside the handle
method.
The currently scoped request. Valid only inside the handle
method.
Attributes
- Inherited from:
- DynamicScope
The currently scoped response. Valid only inside the handle
method.
The currently scoped response. Valid only inside the handle
method.
Attributes
- Inherited from:
- DynamicScope
Attributes
- Inherited from:
- TypeConverterSupport
Implicit convert a (String) => Option[T]
function into a TypeConverter[T]
Implicit convert a (String) => Option[T]
function into a TypeConverter[T]
Attributes
- Inherited from:
- TypeConverterSupport
Attributes
- Inherited from:
- DefaultImplicitConversions
Attributes
- Inherited from:
- DefaultImplicitConversions
The current session. Creates a session if none exists.
Attributes
- Inherited from:
- DefaultImplicitConversions
Attributes
- Inherited from:
- DefaultImplicitConversions
Attributes
- Inherited from:
- DefaultImplicitConversions
Attributes
- Inherited from:
- DefaultImplicitConversions
Attributes
- Inherited from:
- DefaultImplicitConversions
Attributes
- Inherited from:
- DefaultImplicitConversions
Attributes
- Inherited from:
- DefaultImplicitConversions
Attributes
- Inherited from:
- DefaultImplicitConversions
Attributes
- Inherited from:
- ScalatraParamsImplicits
Attributes
- Inherited from:
- ScalatraParamsImplicits