- Since:
- 2.0.2
- Author:
- edgar
-
Field Summary
Fields inherited from interface io.jooby.Context
ACCEPT, GMT, PORT, RFC1123, RFC1123_PATTERN, SECURE_PORT
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
True if the given type matches the `Accept` header.Check if the accept type list matches the given produces list and return the most specific media type from produces list.body()
HTTP body which provides access to body content.<T> T
Convert the HTTP body to the given type.<T> T
Convert the HTTP body to the given type.<T> T
Converts a value (single or hash) into the given type.<T> T
convertOrNull
(ValueNode value, Class<T> type) Converts a value (single or hash) into the given type.Get a cookie matching the given name.Request cookies.<T> T
Convert the HTTP body to the given type.Get a decoder for the given content type or get anStatusCode.UNSUPPORTED_MEDIA_TYPE
.detach
(Route.Handler next) Tells context that response will be generated form a different thread.Dispatch context to a worker threads.Dispatch context to the given executor.A file upload that matches the given field name.files()
All file uploads.All file uploads that matches the given field name.flash()
Flash map.Get a flash attribute.form()
Get form data.<T> T
Convert form data to the given type.Get a form field that matches the given name.formMap()
Form data as single-value map.Forward executing to another route.<T> T
getAttribute
(String key) Get an attribute by his key.Context attributes (a.k.a request attributes).The certificates presented by the client for mutual TLS.getHost()
Return the host that this request was sent to, in general this will be the value of the Host header, minus the port specifier.Return the host and port that this request was sent to, in general this will be the value of the Host.HTTP method in upper-case form.int
getPort()
Return the port that this request was sent to.The name of the protocol the request.The IP address of the client or last proxy that sent the request.long
RequestContent-Length
header or-1
when missing.Request path without decoding (a.k.a raw Path) without query string.RequestContent-Type
header ornull
when missing.getRequestType
(MediaType defaults) RequestContent-Type
header ornull
when missing.Recreates full/entire url of the current request using theHost
header.getRequestURL
(String path) Recreates full/entire request url using theHost
header with a custom path/suffix.boolean
True if response headers are cleared on application error.Get response status code.getResponseHeader
(String name) Get response header.long
Get response content length or-1
when none was set.Get response content type.getRoute()
Matching route.Get the HTTP router (usually this represents an instance ofJooby
.HTTP scheme in lower case.Server host.int
Server port for current request.<T> T
getUser()
Current user ornull
if none was set.header()
Request headers asValueNode
.Get a header that matches the given name.Header as single-value map.boolean
True when request runs in IO threads.boolean
True if response already started.boolean
isSecure()
Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.boolean
Check if the request path matches the given pattern.onComplete
(Route.Complete task) Add a complete listener.path()
ConvertContext.pathMap()
to aValueNode
object.<T> T
Convert theContext.pathMap()
to the given type.Path variable.pathMap()
Path map represent all the path keys with their values.query()
Query string asValueNode
object.<T> T
Convert the queryString to the given type.Get a query parameter that matches the given name.queryMap()
Query string as simple map.Query string with the leading?
or empty string.removeResponseHeader
(String name) Remove a response header.Clear/reset all the headers, including cookies.Render a value and send the response to client.<T> T
require
(ServiceKey<T> key) Provides an instance of the given type.<T> T
Provides an instance of the given type.<T> T
Provides an instance of the given type where name matches it.HTTP response channel as chunker.HTTP response channel as output stream.responseStream
(MediaType contentType) HTTP response channel as output stream.responseStream
(MediaType contentType, SneakyThrows.Consumer<OutputStream> consumer) HTTP response channel as output stream.responseStream
(SneakyThrows.Consumer<OutputStream> consumer) HTTP response channel as output stream.HTTP response channel as response writer.responseWriter
(MediaType contentType) HTTP response channel as response writer.responseWriter
(MediaType contentType, SneakyThrows.Consumer<PrintWriter> consumer) HTTP response channel as response writer.responseWriter
(MediaType contentType, Charset charset) HTTP response channel as response writer.responseWriter
(MediaType contentType, Charset charset, SneakyThrows.Consumer<PrintWriter> consumer) HTTP response channel as response writer.responseWriter
(SneakyThrows.Consumer<PrintWriter> consumer) HTTP response channel as response writer.send
(byte[] data) Send response data.send
(byte[]... data) Send response data.send
(FileDownload file) Send a file download response.send
(StatusCode statusCode) Send an empty response with the given status code.send
(InputStream input) Send response data.Send response data.Send response data.send
(ByteBuffer data) Send response data.send
(ByteBuffer[] data) Send response data.send
(FileChannel file) Send a file response.send
(ReadableByteChannel channel) Send response data.Send a file response.Send an error response.sendError
(Throwable cause, StatusCode code) Send an error response.sendRedirect
(StatusCode redirect, String location) Send a redirect response.sendRedirect
(String location) Send a302
response.session()
Find a session or creates a new session.Find a session attribute using the given name.Find an existing session.setAttribute
(String key, Object value) Set an application attribute.setDefaultResponseType
(MediaType contentType) Set the default response content type header.Set the host (without the port value).Set HTTP method in upper-case form.setPathMap
(Map<String, String> pathMap) Set path map.setPort
(int port) Set port this request was sent to.setRemoteAddress
(String remoteAddress) Set IP address of client or last proxy that sent the request.setRequestPath
(String path) Set request path.setResetHeadersOnError
(boolean value) Set whenever reset/clear headers on application error.setResponseCode
(int statusCode) Set response status code.setResponseCode
(StatusCode statusCode) Set response status code.setResponseCookie
(Cookie cookie) Set/add a cookie to response.setResponseHeader
(String name, Object value) Set response header.setResponseHeader
(String name, String value) Set response header.setResponseHeader
(String name, Instant value) Set response header.setResponseHeader
(String name, Date value) Set response header.setResponseLength
(long length) Set response content length header.setResponseType
(MediaType contentType) Set response content type header.setResponseType
(MediaType contentType, Charset charset) Set response content type header.setResponseType
(String contentType) Set response content type header.Set matching route.Set HTTP scheme in lower case.Set current user.toString()
upgrade
(ServerSentEmitter.Handler handler) Perform a server-sent event handshake and upgrade HTTP GET into a Server-Sent protocol.upgrade
(WebSocket.Initializer handler) Perform a websocket handsahke and upgrade a HTTP GET into a websocket protocol.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface io.jooby.Context
getContextPath, isPreflight, locale, locale, locales, locales, lookup, lookup, lookup
-
Constructor Details
-
ForwardingContext
Creates a new forwarding context.- Parameters:
context
- Source context.
-
-
Method Details
-
getUser
@Nullable public <T> T getUser()Description copied from interface:Context
Current user ornull
if none was set. -
setUser
Description copied from interface:Context
Set current user. -
forward
Description copied from interface:Context
Forward executing to another route. We use the given path to find a matching route.NOTE: the entire handler pipeline is executed (filter, decorator, etc.).
-
matches
Description copied from interface:Context
Check if the request path matches the given pattern. -
isSecure
public boolean isSecure()Description copied from interface:Context
Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS. -
getAttributes
Description copied from interface:Context
Context attributes (a.k.a request attributes).- Specified by:
getAttributes
in interfaceContext
- Returns:
- Mutable Context attributes.
-
getAttribute
Description copied from interface:Context
Get an attribute by his key. This is just an utility method aroundContext.getAttributes()
. This method look first in current context and fallback to application attributes.- Specified by:
getAttribute
in interfaceContext
- Type Parameters:
T
- Attribute type.- Parameters:
key
- Attribute key.- Returns:
- Attribute value or
null
.
-
setAttribute
Description copied from interface:Context
Set an application attribute.- Specified by:
setAttribute
in interfaceContext
- Parameters:
key
- Attribute key.value
- Attribute value.- Returns:
- This router.
-
getRouter
Description copied from interface:Context
Get the HTTP router (usually this represents an instance ofJooby
. -
flash
Description copied from interface:Context
Flash map. -
flash
Description copied from interface:Context
Get a flash attribute. -
session
Description copied from interface:Context
Find a session attribute using the given name. If there is no session or attribute under that name a missing value is returned. -
session
Description copied from interface:Context
Find a session or creates a new session. -
sessionOrNull
Description copied from interface:Context
Find an existing session.- Specified by:
sessionOrNull
in interfaceContext
- Returns:
- Existing session or
null
.
-
cookie
Description copied from interface:Context
Get a cookie matching the given name. -
cookieMap
Description copied from interface:Context
Request cookies. -
getMethod
Description copied from interface:Context
HTTP method in upper-case form. -
setMethod
Description copied from interface:Context
Set HTTP method in upper-case form. -
getRoute
Description copied from interface:Context
Matching route. -
setRoute
Description copied from interface:Context
Set matching route. This is part of public API, but shouldn't be use by application code. -
getRequestPath
Description copied from interface:Context
Request path without decoding (a.k.a raw Path) without query string.- Specified by:
getRequestPath
in interfaceContext
- Returns:
- Request path without decoding (a.k.a raw Path) without query string.
-
setRequestPath
Description copied from interface:Context
Set request path. This is usually done by Web Server or framework, but by user.- Specified by:
setRequestPath
in interfaceContext
- Parameters:
path
- Request path.- Returns:
- This context.
-
path
Description copied from interface:Context
Path variable. Value is decoded. -
path
Description copied from interface:Context
Convert theContext.pathMap()
to the given type. -
path
Description copied from interface:Context
ConvertContext.pathMap()
to aValueNode
object. -
pathMap
Description copied from interface:Context
Path map represent all the path keys with their values.
A call to:{ get("/:id", ctx -> ctx.pathMap()); }
GET /678
Produces a path map like:id: 678
-
setPathMap
Description copied from interface:Context
Set path map. This method is part of public API but shouldn't be use it by application code.- Specified by:
setPathMap
in interfaceContext
- Parameters:
pathMap
- Path map.- Returns:
- This context.
-
query
Description copied from interface:Context
Query string asValueNode
object. -
query
Description copied from interface:Context
Get a query parameter that matches the given name.{ get("/search", ctx -> { String q = ctx.query("q").value(); ... }); }
-
queryString
Description copied from interface:Context
Query string with the leading?
or empty string. This is the raw query string, without decoding it.- Specified by:
queryString
in interfaceContext
- Returns:
- Query string with the leading
?
or empty string. This is the raw query string, without decoding it.
-
query
Description copied from interface:Context
Convert the queryString to the given type. -
queryMap
Description copied from interface:Context
Query string as simple map.
Produces/search?q=jooby&sort=name
{q: jooby, sort: name}
-
header
Description copied from interface:Context
Request headers asValueNode
. -
header
Description copied from interface:Context
Get a header that matches the given name. -
headerMap
Description copied from interface:Context
Header as single-value map. -
accept
Description copied from interface:Context
True if the given type matches the `Accept` header. This method returnstrue
if there is no accept header. -
accept
Description copied from interface:Context
Check if the accept type list matches the given produces list and return the most specific media type from produces list. -
getRequestType
Description copied from interface:Context
RequestContent-Type
header ornull
when missing.- Specified by:
getRequestType
in interfaceContext
- Returns:
- Request
Content-Type
header ornull
when missing.
-
getRequestType
Description copied from interface:Context
RequestContent-Type
header ornull
when missing.- Specified by:
getRequestType
in interfaceContext
- Parameters:
defaults
- Default content type to use when the header is missing.- Returns:
- Request
Content-Type
header ornull
when missing.
-
getRequestLength
public long getRequestLength()Description copied from interface:Context
RequestContent-Length
header or-1
when missing.- Specified by:
getRequestLength
in interfaceContext
- Returns:
- Request
Content-Length
header or-1
when missing.
-
getRemoteAddress
Description copied from interface:Context
The IP address of the client or last proxy that sent the request.If you run behind a reverse proxy that has been configured to send the X-Forwarded-* header, please consider to set
Router.setTrustProxy(boolean)
option.- Specified by:
getRemoteAddress
in interfaceContext
- Returns:
- The IP address of the client or last proxy that sent the request or
empty string
for interrupted requests.
-
setRemoteAddress
Description copied from interface:Context
Set IP address of client or last proxy that sent the request.- Specified by:
setRemoteAddress
in interfaceContext
- Parameters:
remoteAddress
- Remote Address.- Returns:
- This context.
-
getHost
Description copied from interface:Context
Return the host that this request was sent to, in general this will be the value of the Host header, minus the port specifier. Unless, it is set manually using theContext.setHost(String)
method.If you run behind a reverse proxy that has been configured to send the X-Forwarded-* header, please consider to set
Router.setTrustProxy(boolean)
option. -
setHost
Description copied from interface:Context
Set the host (without the port value).Please keep in mind this method doesn't alter/modify the
host
header. -
getServerPort
public int getServerPort()Description copied from interface:Context
Server port for current request.- Specified by:
getServerPort
in interfaceContext
- Returns:
- Server port for current request.
-
getServerHost
Description copied from interface:Context
Server host.- Specified by:
getServerHost
in interfaceContext
- Returns:
- Server host.
-
getPort
public int getPort()Description copied from interface:Context
Return the port that this request was sent to. In general this will be the value of the Host header, minus the host name.If no host header is present, this method returns the value of
Context.getServerPort()
. -
setPort
Description copied from interface:Context
Set port this request was sent to. -
getHostAndPort
Description copied from interface:Context
Return the host and port that this request was sent to, in general this will be the value of the Host.If you run behind a reverse proxy that has been configured to send the X-Forwarded-* header, please consider to set
Router.setTrustProxy(boolean)
option.- Specified by:
getHostAndPort
in interfaceContext
- Returns:
- Return the host that this request was sent to, in general this will be the value of the Host header.
-
getRequestURL
Description copied from interface:Context
Recreates full/entire url of the current request using theHost
header.If you run behind a reverse proxy that has been configured to send the X-Forwarded-* header, please consider to set
Router.setTrustProxy(boolean)
option.- Specified by:
getRequestURL
in interfaceContext
- Returns:
- Full/entire request url using the
Host
header.
-
getRequestURL
Description copied from interface:Context
Recreates full/entire request url using theHost
header with a custom path/suffix.If you run behind a reverse proxy that has been configured to send the X-Forwarded-* header, please consider to set
Router.setTrustProxy(boolean)
option.- Specified by:
getRequestURL
in interfaceContext
- Parameters:
path
- Path or suffix to use, can also include query string parameters.- Returns:
- Full/entire request url using the
Host
header.
-
getProtocol
Description copied from interface:Context
The name of the protocol the request. Always in lower-case.- Specified by:
getProtocol
in interfaceContext
- Returns:
- The name of the protocol the request. Always in lower-case.
-
getClientCertificates
Description copied from interface:Context
The certificates presented by the client for mutual TLS. Empty if ssl is not enabled, or client authentication is not required.- Specified by:
getClientCertificates
in interfaceContext
- Returns:
- The certificates presented by the client for mutual TLS. Empty if ssl is not enabled, or client authentication is not required.
-
getScheme
Description copied from interface:Context
HTTP scheme in lower case. -
setScheme
Description copied from interface:Context
Set HTTP scheme in lower case. -
form
Description copied from interface:Context
Get form data.Only for
application/x-www-form-urlencoded
ormultipart/form-data
request. -
form
Description copied from interface:Context
Get a form field that matches the given name.File upload retrieval is available using
Context.file(String)
.Only for
multipart/form-data
request. -
form
Description copied from interface:Context
Convert form data to the given type.Only for
application/x-www-form-urlencoded
ormultipart/form-data
request. -
formMap
Description copied from interface:Context
Form data as single-value map.Only for
application/x-www-form-urlencoded
ormultipart/form-data
request. -
files
Description copied from interface:Context
All file uploads. Only formultipart/form-data
request. -
files
Description copied from interface:Context
All file uploads that matches the given field name.Only for
multipart/form-data
request. -
file
Description copied from interface:Context
A file upload that matches the given field name.Only for
multipart/form-data
request. -
body
Description copied from interface:Context
HTTP body which provides access to body content. -
body
Description copied from interface:Context
Convert the HTTP body to the given type. -
body
Description copied from interface:Context
Convert the HTTP body to the given type. -
convert
Description copied from interface:Context
Converts a value (single or hash) into the given type. -
convertOrNull
Description copied from interface:Context
Converts a value (single or hash) into the given type.- Specified by:
convertOrNull
in interfaceContext
- Type Parameters:
T
- Generic type.- Parameters:
value
- Value to convert.type
- Expected type.- Returns:
- Converted value or
null
.
-
decode
Description copied from interface:Context
Convert the HTTP body to the given type. -
decoder
Description copied from interface:Context
Get a decoder for the given content type or get anStatusCode.UNSUPPORTED_MEDIA_TYPE
. -
isInIoThread
public boolean isInIoThread()Description copied from interface:Context
True when request runs in IO threads.- Specified by:
isInIoThread
in interfaceContext
- Returns:
- True when request runs in IO threads.
-
dispatch
Description copied from interface:Context
Dispatch context to a worker threads. Worker threads allow to execute blocking code. The default worker thread pool is provided by web server or by application code using theJooby.setWorker(Executor)
.Example:
get("/", ctx -> { return ctx.dispatch(() -> { // run blocking code }): });
-
dispatch
Description copied from interface:Context
Dispatch context to the given executor.Example:
Executor executor = ...; get("/", ctx -> { return ctx.dispatch(executor, () -> { // run blocking code }): });
-
detach
Description copied from interface:Context
Tells context that response will be generated form a different thread. This operation is similar toContext.dispatch(Runnable)
except there is no thread dispatching here.This operation integrates easily with third-party libraries like rxJava or others.
-
upgrade
Description copied from interface:Context
Perform a websocket handsahke and upgrade a HTTP GET into a websocket protocol.NOTE: This method is part of Public API, but shouldn't be used by client code.
-
upgrade
Description copied from interface:Context
Perform a server-sent event handshake and upgrade HTTP GET into a Server-Sent protocol.NOTE: This method is part of Public API, but shouldn't be used by client code.
-
setResponseHeader
Description copied from interface:Context
Set response header.- Specified by:
setResponseHeader
in interfaceContext
- Parameters:
name
- Header name.value
- Header value.- Returns:
- This context.
-
setResponseHeader
Description copied from interface:Context
Set response header.- Specified by:
setResponseHeader
in interfaceContext
- Parameters:
name
- Header name.value
- Header value.- Returns:
- This context.
-
setResponseHeader
Description copied from interface:Context
Set response header.- Specified by:
setResponseHeader
in interfaceContext
- Parameters:
name
- Header name.value
- Header value.- Returns:
- This context.
-
setResponseHeader
Description copied from interface:Context
Set response header.- Specified by:
setResponseHeader
in interfaceContext
- Parameters:
name
- Header name.value
- Header value.- Returns:
- This context.
-
removeResponseHeader
Description copied from interface:Context
Remove a response header.- Specified by:
removeResponseHeader
in interfaceContext
- Parameters:
name
- Header's name.- Returns:
- This context.
-
removeResponseHeaders
Description copied from interface:Context
Clear/reset all the headers, including cookies.- Specified by:
removeResponseHeaders
in interfaceContext
- Returns:
- This context.
-
getResponseHeader
Description copied from interface:Context
Get response header.- Specified by:
getResponseHeader
in interfaceContext
- Parameters:
name
- Header's name.- Returns:
- Header's value (if set previously) or
null
.
-
getResponseLength
public long getResponseLength()Description copied from interface:Context
Get response content length or-1
when none was set.- Specified by:
getResponseLength
in interfaceContext
- Returns:
- Response content length or
-1
when none was set.
-
setResponseLength
Description copied from interface:Context
Set response content length header.- Specified by:
setResponseLength
in interfaceContext
- Parameters:
length
- Response length.- Returns:
- This context.
-
setResponseCookie
Description copied from interface:Context
Set/add a cookie to response.- Specified by:
setResponseCookie
in interfaceContext
- Parameters:
cookie
- Cookie to add.- Returns:
- This context.
-
setResponseType
Description copied from interface:Context
Set response content type header.- Specified by:
setResponseType
in interfaceContext
- Parameters:
contentType
- Content type.- Returns:
- This context.
-
setResponseType
Description copied from interface:Context
Set response content type header.- Specified by:
setResponseType
in interfaceContext
- Parameters:
contentType
- Content type.- Returns:
- This context.
-
setResponseType
Description copied from interface:Context
Set response content type header.- Specified by:
setResponseType
in interfaceContext
- Parameters:
contentType
- Content type.charset
- Charset.- Returns:
- This context.
-
setDefaultResponseType
Description copied from interface:Context
Set the default response content type header. It is used if the response content type header was not set yet.- Specified by:
setDefaultResponseType
in interfaceContext
- Parameters:
contentType
- Content type.- Returns:
- This context.
-
getResponseType
Description copied from interface:Context
Get response content type.- Specified by:
getResponseType
in interfaceContext
- Returns:
- Response content type.
-
setResponseCode
Description copied from interface:Context
Set response status code.- Specified by:
setResponseCode
in interfaceContext
- Parameters:
statusCode
- Status code.- Returns:
- This context.
-
setResponseCode
Description copied from interface:Context
Set response status code.- Specified by:
setResponseCode
in interfaceContext
- Parameters:
statusCode
- Status code.- Returns:
- This context.
-
getResponseCode
Description copied from interface:Context
Get response status code.- Specified by:
getResponseCode
in interfaceContext
- Returns:
- Response status code.
-
render
Description copied from interface:Context
Render a value and send the response to client. -
responseStream
Description copied from interface:Context
HTTP response channel as output stream. Usually for chunked responses.- Specified by:
responseStream
in interfaceContext
- Returns:
- HTTP channel as output stream. Usually for chunked responses.
-
responseStream
Description copied from interface:Context
HTTP response channel as output stream. Usually for chunked responses.- Specified by:
responseStream
in interfaceContext
- Parameters:
contentType
- Media type.- Returns:
- HTTP channel as output stream. Usually for chunked responses.
-
responseStream
@NonNull public Context responseStream(@NonNull MediaType contentType, @NonNull SneakyThrows.Consumer<OutputStream> consumer) throws Exception Description copied from interface:Context
HTTP response channel as output stream. Usually for chunked responses.- Specified by:
responseStream
in interfaceContext
- Parameters:
contentType
- Content type.consumer
- Output stream consumer.- Returns:
- HTTP channel as output stream. Usually for chunked responses.
- Throws:
Exception
- Is something goes wrong.
-
responseStream
@NonNull public Context responseStream(@NonNull SneakyThrows.Consumer<OutputStream> consumer) throws Exception Description copied from interface:Context
HTTP response channel as output stream. Usually for chunked responses.- Specified by:
responseStream
in interfaceContext
- Parameters:
consumer
- Output stream consumer.- Returns:
- HTTP channel as output stream. Usually for chunked responses.
- Throws:
Exception
- Is something goes wrong.
-
responseSender
Description copied from interface:Context
HTTP response channel as chunker.- Specified by:
responseSender
in interfaceContext
- Returns:
- HTTP channel as chunker. Usually for chunked response.
-
responseWriter
Description copied from interface:Context
HTTP response channel as response writer.- Specified by:
responseWriter
in interfaceContext
- Returns:
- HTTP channel as response writer. Usually for chunked response.
-
responseWriter
Description copied from interface:Context
HTTP response channel as response writer.- Specified by:
responseWriter
in interfaceContext
- Parameters:
contentType
- Content type.- Returns:
- HTTP channel as response writer. Usually for chunked response.
-
responseWriter
@NonNull public PrintWriter responseWriter(@NonNull MediaType contentType, @Nullable Charset charset) Description copied from interface:Context
HTTP response channel as response writer.- Specified by:
responseWriter
in interfaceContext
- Parameters:
contentType
- Content type.charset
- Charset.- Returns:
- HTTP channel as response writer. Usually for chunked response.
-
responseWriter
@NonNull public Context responseWriter(@NonNull SneakyThrows.Consumer<PrintWriter> consumer) throws Exception Description copied from interface:Context
HTTP response channel as response writer.- Specified by:
responseWriter
in interfaceContext
- Parameters:
consumer
- Writer consumer.- Returns:
- This context.
- Throws:
Exception
- Is something goes wrong.
-
responseWriter
@NonNull public Context responseWriter(@NonNull MediaType contentType, @NonNull SneakyThrows.Consumer<PrintWriter> consumer) throws Exception Description copied from interface:Context
HTTP response channel as response writer.- Specified by:
responseWriter
in interfaceContext
- Parameters:
contentType
- Content type.consumer
- Writer consumer.- Returns:
- This context.
- Throws:
Exception
- Is something goes wrong.
-
responseWriter
@NonNull public Context responseWriter(@NonNull MediaType contentType, @Nullable Charset charset, @NonNull SneakyThrows.Consumer<PrintWriter> consumer) throws Exception Description copied from interface:Context
HTTP response channel as response writer.- Specified by:
responseWriter
in interfaceContext
- Parameters:
contentType
- Content type.charset
- Charset.consumer
- Writer consumer.- Returns:
- This context.
- Throws:
Exception
- Is something goes wrong.
-
sendRedirect
Description copied from interface:Context
Send a302
response.- Specified by:
sendRedirect
in interfaceContext
- Parameters:
location
- Location.- Returns:
- This context.
-
sendRedirect
Description copied from interface:Context
Send a redirect response.- Specified by:
sendRedirect
in interfaceContext
- Parameters:
redirect
- Redirect status code.location
- Location.- Returns:
- This context.
-
send
Description copied from interface:Context
Send response data. -
send
Description copied from interface:Context
Send response data. -
send
Description copied from interface:Context
Send response data. -
send
Description copied from interface:Context
Send response data. -
send
Description copied from interface:Context
Send response data. -
send
Description copied from interface:Context
Send response data. -
send
Description copied from interface:Context
Send response data. -
send
Description copied from interface:Context
Send response data. -
send
Description copied from interface:Context
Send a file download response. -
send
Description copied from interface:Context
Send a file response. -
send
Description copied from interface:Context
Send a file response. -
send
Description copied from interface:Context
Send an empty response with the given status code. -
sendError
Description copied from interface:Context
Send an error response. Status code is computed viaRouter.errorCode(Throwable)
. -
sendError
Description copied from interface:Context
Send an error response. -
isResponseStarted
public boolean isResponseStarted()Description copied from interface:Context
True if response already started.- Specified by:
isResponseStarted
in interfaceContext
- Returns:
- True if response already started.
-
getResetHeadersOnError
public boolean getResetHeadersOnError()Description copied from interface:Context
True if response headers are cleared on application error. If none set it uses the default/global value specified byRouterOption.RESET_HEADERS_ON_ERROR
.- Specified by:
getResetHeadersOnError
in interfaceContext
- Returns:
- True if response headers are cleared on application error. If none set it uses the
default/global value specified by
RouterOption.RESET_HEADERS_ON_ERROR
.
-
setResetHeadersOnError
Description copied from interface:Context
Set whenever reset/clear headers on application error.- Specified by:
setResetHeadersOnError
in interfaceContext
- Parameters:
value
- True for reset/clear headers.- Returns:
- This context.
-
onComplete
Description copied from interface:Context
Add a complete listener.- Specified by:
onComplete
in interfaceContext
- Parameters:
task
- Task to execute.- Returns:
- This context.
-
require
Description copied from interface:Registry
Provides an instance of the given type.- Specified by:
require
in interfaceRegistry
- Type Parameters:
T
- Object type.- Parameters:
type
- Object type.- Returns:
- Instance of this type.
- Throws:
RegistryException
- If there was a runtime failure while providing an instance.
-
require
@NonNull public <T> T require(@NonNull Class<T> type, @NonNull String name) throws RegistryException Description copied from interface:Registry
Provides an instance of the given type where name matches it.- Specified by:
require
in interfaceRegistry
- Type Parameters:
T
- Object type.- Parameters:
type
- Object type.name
- Object name.- Returns:
- Instance of this type.
- Throws:
RegistryException
- If there was a runtime failure while providing an instance.
-
require
Description copied from interface:Registry
Provides an instance of the given type.- Specified by:
require
in interfaceRegistry
- Type Parameters:
T
- Object type.- Parameters:
key
- Object key.- Returns:
- Instance of this type.
- Throws:
RegistryException
- If there was a runtime failure while providing an instance.
-
toString
-