Additionally, contains metadata about route return Java type, argument source (query, path, etc..) and Java type.
This class contains all the metadata associated to a route. It is like a Class
object
for routes.
- Since:
- 2.0.0
- Author:
- edgar
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Execute application logic after a response has been generated by a route handler.static interface
static interface
Decorates a handler and run logic before handler is executed.static interface
Listener interface for events that are run at the completion of a request/response cycle (i.e.static interface
Deprecated.static interface
Decorates a route handler by running logic before and after route handler.static interface
Route handler here is where the application logic lives. -
Field Summary
Modifier and TypeFieldDescriptionstatic final Route.Before
Handler forStatusCode.NOT_ACCEPTABLE
responses.static final Route.Handler
Favicon handler as a silent 404 error.static final Route.Handler
Handler forStatusCode.METHOD_NOT_ALLOWED
responses.static final Route.Handler
Handler forStatusCode.NOT_FOUND
responses.static final Route.Handler
Handler forStatusCode.REQUEST_ENTITY_TOO_LARGE
responses.static final Route.Before
Handler forStatusCode.UNSUPPORTED_MEDIA_TYPE
responses. -
Constructor Summary
ConstructorDescriptionRoute
(String method, String pattern, Route.Handler handler) Creates a new route. -
Method Summary
Modifier and TypeMethodDescriptionAdd a tag to this route.<T> T
Retrieve value of this specific Attribute set to this route.Add one or more attributes applied to this route.Add one or more request types (format) consumed by this route.MessageDecoder for given media type.description
(String description) Route description useful for documentation purpose from openAPI generator.getAfter()
After filter ornull
.Attributes set to this route.Request types (format) consumed by this route.Route message decoder.Route description useful for documentation purpose from openAPI generator.Route encoder.Specify the name of the executor where the route is going to run.Decorator ornull
.Handler instance which might or might not be the same asgetHandler()
.Route handler.HTTP method.Method for MVC/Controller.Path keys.Path pattern.Route pipeline.Response types (format) produces by this route.Route return type.Route summary useful for documentation purpose from openAPI generator.getTags()
Route tags.boolean
True if route support HTTP HEAD.boolean
True if route support HTTP OPTIONS.boolean
True if route support HTTP TRACE.boolean
Truth when route is non-blocking.boolean
Test if theisNonBlocking()
flag was set or not.boolean
isTransactional
(boolean defaultValue) Returns whether this route is marked as transactional, or returnsdefaultValue
if this route has not been marked explicitly.Set mvc/controller method.Add one or more response types (format) produces by this route.Recreate a path pattern using the given variables.Recreate a path pattern using the given variables.setAfter
(Route.After after) Set after filter.setAttributes
(Map<String, Object> attributes) Add one or more attributes applied to this route.setConsumes
(Collection<MediaType> consumes) Add one or more request types (format) consumed by this route.setDecoders
(Map<String, MessageDecoder> decoders) Set message decoders.setDescription
(String description) Route description useful for documentation purpose from openAPI generator.setEncoder
(MessageEncoder encoder) Set encoder.setExecutorKey
(String executorKey) Set executor key.setFilter
(Route.Filter filter) Set route filter.Set route handle instance, required when handle is different fromgetHandler()
.setHttpHead
(boolean enabled) Enabled or disabled HTTP HEAD.setHttpOptions
(boolean enabled) Enabled or disabled HTTP Options.setHttpTrace
(boolean enabled) Enabled or disabled HTTP TRACE.setMvcMethod
(Method mvcMethod) Set mvc/controller method.setNonBlocking
(boolean nonBlocking) Set when the route is blocking or non-blocking.setPathKeys
(List<String> pathKeys) Set path keys.setPipeline
(Route.Handler pipeline) Set route pipeline.setProduces
(Collection<MediaType> produces) Add one or more response types (format) produces by this route.setReturnType
(Type returnType) Set route return type.setSummary
(String summary) Route summary useful for documentation purpose from openAPI generator.Tag this route.Route summary useful for documentation purpose from openAPI generator.Tag this route.toString()
-
Field Details
-
NOT_FOUND
Handler forStatusCode.NOT_FOUND
responses. -
METHOD_NOT_ALLOWED
Handler forStatusCode.METHOD_NOT_ALLOWED
responses. -
REQUEST_ENTITY_TOO_LARGE
Handler forStatusCode.REQUEST_ENTITY_TOO_LARGE
responses. -
ACCEPT
Handler forStatusCode.NOT_ACCEPTABLE
responses. -
SUPPORT_MEDIA_TYPE
Handler forStatusCode.UNSUPPORTED_MEDIA_TYPE
responses. -
FAVICON
Favicon handler as a silent 404 error.
-
-
Constructor Details
-
Route
Creates a new route.- Parameters:
method
- HTTP method.pattern
- Path pattern.handler
- Route handler.
-
-
Method Details
-
getPattern
Path pattern.- Returns:
- Path pattern.
-
getMethod
HTTP method.- Returns:
- HTTP method.
-
getPathKeys
Path keys.- Returns:
- Path keys.
-
setPathKeys
Set path keys.- Parameters:
pathKeys
- Path keys or empty list.- Returns:
- This route.
-
getHandler
Route handler.- Returns:
- Route handler.
-
getPipeline
Route pipeline.- Returns:
- Route pipeline.
-
reverse
Recreate a path pattern using the given variables.reserve(/{k1}/{k2}, {"k1": ""foo", "k2": "bar"}) => /foo/bar
- Parameters:
keys
- Path keys.- Returns:
- Path.
-
reverse
Recreate a path pattern using the given variables.reserve(/{k1}/{k2}, "foo", "bar") => /foo/bar
- Parameters:
values
- Values.- Returns:
- Path.
-
getHandle
Handler instance which might or might not be the same asgetHandler()
.The handle is required to extract correct metadata.
- Returns:
- Handle.
-
getAfter
After filter ornull
.- Returns:
- After filter or
null
.
-
setAfter
Set after filter.- Parameters:
after
- After filter.- Returns:
- This route.
-
getFilter
Decorator ornull
.- Returns:
- Decorator or
null
.
-
setFilter
Set route filter.- Parameters:
filter
- Filter.- Returns:
- This route.
-
setHandle
Set route handle instance, required when handle is different fromgetHandler()
.- Parameters:
handle
- Handle instance.- Returns:
- This route.
-
setPipeline
Set route pipeline. This method is part of public API but isn't intended to be used by public.- Parameters:
pipeline
- Pipeline.- Returns:
- This routes.
-
getEncoder
Route encoder.- Returns:
- Route encoder.
-
setEncoder
Set encoder.- Parameters:
encoder
- MessageEncoder.- Returns:
- This route.
-
isNonBlocking
@NonNull public boolean isNonBlocking()Truth when route is non-blocking. False otherwise. Blocking code isn't allowed for non-blocking routes.Default is
blocking
ornon-blocking=false
. Except when you startup your application usingExecutionMode.EVENT_LOOP
.- Returns:
- Truth when route is non-blocking. False otherwise or
null
otherwise.
-
isNonBlockingSet
public boolean isNonBlockingSet()Test if theisNonBlocking()
flag was set or not. Internal use only.- Returns:
- Test if the
isNonBlocking()
flag was set or not. Internal use only.
-
setNonBlocking
Set when the route is blocking or non-blocking.Default is
blocking
ornon-blocking=false
. Except when you startup your application usingExecutionMode.EVENT_LOOP
.- Parameters:
nonBlocking
- True for non-blocking routes.- Returns:
-
getReturnType
Route return type.- Returns:
- Return type.
-
setReturnType
Set route return type.- Parameters:
returnType
- Return type.- Returns:
- This route.
-
getProduces
Response types (format) produces by this route. If set, we expect to find a match in theAccept
header. If none matches, we send aStatusCode.NOT_ACCEPTABLE
response.- Returns:
- Immutable list of produce types.
-
produces
Add one or more response types (format) produces by this route.- Parameters:
produces
- Produce types.- Returns:
- This route.
-
setProduces
Add one or more response types (format) produces by this route.- Parameters:
produces
- Produce types.- Returns:
- This route.
-
getConsumes
Request types (format) consumed by this route. If set theContent-Type
header is checked against these values. If none matches we send aStatusCode.UNSUPPORTED_MEDIA_TYPE
exception.- Returns:
- Immutable list of consumed types.
-
consumes
Add one or more request types (format) consumed by this route.- Parameters:
consumes
- Consume types.- Returns:
- This route.
-
setConsumes
Add one or more request types (format) consumed by this route.- Parameters:
consumes
- Consume types.- Returns:
- This route.
-
getAttributes
Attributes set to this route.- Returns:
- Map of attributes set to the route.
-
attribute
Retrieve value of this specific Attribute set to this route.- Type Parameters:
T
- Generic type.- Parameters:
name
- of the attribute to retrieve.- Returns:
- value of the specific attribute.
-
setAttributes
Add one or more attributes applied to this route.- Parameters:
attributes
- .- Returns:
- This route.
-
attribute
Add one or more attributes applied to this route.- Parameters:
name
- attribute namevalue
- attribute value- Returns:
- This route.
-
decoder
MessageDecoder for given media type.- Parameters:
contentType
- Media type.- Returns:
- MessageDecoder.
-
getDecoders
Route message decoder.- Returns:
- Message decoders.
-
setDecoders
Set message decoders. Map key is a mime-type.- Parameters:
decoders
- message decoder.- Returns:
- This route.
-
isHttpOptions
public boolean isHttpOptions()True if route support HTTP OPTIONS.- Returns:
- True if route support HTTP OPTIONS.
-
isHttpTrace
public boolean isHttpTrace()True if route support HTTP TRACE.- Returns:
- True if route support HTTP TRACE.
-
isHttpHead
public boolean isHttpHead()True if route support HTTP HEAD.- Returns:
- True if route support HTTP HEAD.
-
setHttpOptions
Enabled or disabled HTTP Options.- Parameters:
enabled
- Enabled or disabled HTTP Options.- Returns:
- This route.
-
setHttpTrace
Enabled or disabled HTTP TRACE.- Parameters:
enabled
- Enabled or disabled HTTP TRACE.- Returns:
- This route.
-
setHttpHead
Enabled or disabled HTTP HEAD.- Parameters:
enabled
- Enabled or disabled HTTP HEAD.- Returns:
- This route.
-
getExecutorKey
Specify the name of the executor where the route is going to run. Default isnull
.- Returns:
- Executor key.
-
setExecutorKey
Set executor key. The route is going to use the given key to fetch an executor. Possible values are:-
null
: no specific executor, uses the default Jooby logic to choose one, based on the value ofExecutionMode
; -worker
: use the executor provided by the server. -arbitrary name
: use an named executor which as registered usingRouter.executor(String, Executor)
.- Parameters:
executorKey
- Executor key.- Returns:
- This route.
-
getTags
Route tags.- Returns:
- Route tags.
-
setTags
Tag this route. Tags are used for documentation purpose from openAPI generator.- Parameters:
tags
- Tags.- Returns:
- This route.
-
addTag
Add a tag to this route.Tags are used for documentation purpose from openAPI generator.
- Parameters:
tag
- Tag.- Returns:
- This route.
-
tags
Tag this route. Tags are used for documentation purpose from openAPI generator.- Parameters:
tags
- Tags.- Returns:
- This route.
-
getSummary
Route summary useful for documentation purpose from openAPI generator.- Returns:
- Summary.
-
summary
Route summary useful for documentation purpose from openAPI generator.- Parameters:
summary
- Summary.- Returns:
- This route.
-
setSummary
Route summary useful for documentation purpose from openAPI generator.- Parameters:
summary
- Summary.- Returns:
- This route.
-
getDescription
Route description useful for documentation purpose from openAPI generator.- Returns:
- Route description.
-
setDescription
Route description useful for documentation purpose from openAPI generator.- Parameters:
description
- Description.- Returns:
- This route.
-
description
Route description useful for documentation purpose from openAPI generator.- Parameters:
description
- Description.- Returns:
- This route.
-
isTransactional
public boolean isTransactional(boolean defaultValue) Returns whether this route is marked as transactional, or returnsdefaultValue
if this route has not been marked explicitly.- Parameters:
defaultValue
- the value to return if this route was not explicitly marked- Returns:
- whether this route should be considered as transactional
-
getMvcMethod
Method for MVC/Controller. Not available for lambda routes.- Returns:
- Method for MVC/Controller. Not available for lambda routes.
-
setMvcMethod
Set mvc/controller method.- Parameters:
mvcMethod
- Mvc/controller method.- Returns:
- This route
-
mvcMethod
Set mvc/controller method.- Parameters:
mvcMethod
- Mvc/controller method.- Returns:
- This route
-
toString
-
Route.Filter
.