public class ReadOnlyContext extends ForwardingContext
ACCEPT, GMT, PORT, RFC1123, RFC1123_PATTERN, SECURE_PORT
Constructor and Description |
---|
ReadOnlyContext(Context context) |
Modifier and Type | Method and Description |
---|---|
boolean |
isResponseStarted()
True if response already started.
|
Context |
removeResponseHeader(String name)
Remove a response header.
|
Context |
render(Object value)
Render a value and send the response to client.
|
Sender |
responseSender()
HTTP response channel as chunker.
|
OutputStream |
responseStream()
HTTP response channel as output stream.
|
OutputStream |
responseStream(MediaType contentType)
HTTP response channel as output stream.
|
Context |
responseStream(MediaType contentType,
SneakyThrows.Consumer<OutputStream> consumer)
HTTP response channel as output stream.
|
Context |
responseStream(SneakyThrows.Consumer<OutputStream> consumer)
HTTP response channel as output stream.
|
PrintWriter |
responseWriter()
HTTP response channel as response writer.
|
PrintWriter |
responseWriter(MediaType contentType)
HTTP response channel as response writer.
|
PrintWriter |
responseWriter(MediaType contentType,
Charset charset)
HTTP response channel as response writer.
|
Context |
responseWriter(MediaType contentType,
Charset charset,
SneakyThrows.Consumer<PrintWriter> consumer)
HTTP response channel as response writer.
|
Context |
responseWriter(MediaType contentType,
SneakyThrows.Consumer<PrintWriter> consumer)
HTTP response channel as response writer.
|
Context |
responseWriter(SneakyThrows.Consumer<PrintWriter> consumer)
HTTP response channel as response writer.
|
Context |
send(AttachedFile file)
Send a file attached response.
|
Context |
send(byte[] data)
Send response data.
|
Context |
send(ByteBuffer data)
Send response data.
|
Context |
send(FileChannel file)
Send a file response.
|
Context |
send(InputStream input)
Send response data.
|
Context |
send(Path file)
Send a file response.
|
Context |
send(ReadableByteChannel channel)
Send response data.
|
Context |
send(StatusCode statusCode)
Send an empty response with the given status code.
|
Context |
send(String data)
Send response data.
|
Context |
send(String data,
Charset charset)
Send response data.
|
Context |
sendError(Throwable cause)
Send an error response.
|
Context |
sendError(Throwable cause,
StatusCode statusCode)
Send an error response.
|
Context |
sendRedirect(StatusCode redirect,
String location)
Send a redirect response.
|
Context |
sendRedirect(String location)
Send a
302 response. |
Context |
setDefaultResponseType(MediaType contentType)
Set the default response content type header.
|
Context |
setResponseCode(int statusCode)
Set response status code.
|
Context |
setResponseCode(StatusCode statusCode)
Set response status code.
|
Context |
setResponseCookie(Cookie cookie)
Set/add a cookie to response.
|
Context |
setResponseHeader(String name,
Date value)
Set response header.
|
Context |
setResponseHeader(String name,
Instant value)
Set response header.
|
Context |
setResponseHeader(String name,
Object value)
Set response header.
|
Context |
setResponseHeader(String name,
String value)
Set response header.
|
Context |
setResponseLength(long length)
Set response content length header.
|
Context |
setResponseType(MediaType contentType)
Set response content type header.
|
Context |
setResponseType(MediaType contentType,
Charset charset)
Set response content type header.
|
Context |
setResponseType(String contentType)
Set response content type header.
|
accept, accept, attribute, attribute, body, body, body, convert, cookie, cookieMap, decode, decoder, detach, dispatch, dispatch, file, files, files, flash, flash, form, form, form, formMap, formMultimap, getAttributes, getHost, getHostAndPort, getMethod, getPort, getProtocol, getRemoteAddress, getRequestLength, getRequestPath, getRequestType, getRequestType, getRequestURL, getRequestURL, getRequestURL, getRequestURL, getResetHeadersOnError, getResponseCode, getResponseLength, getResponseType, getRoute, getRouter, getScheme, getServerHost, getServerPort, getUser, header, header, headerMap, headerMultimap, isInIoThread, isSecure, matches, multipart, multipart, multipart, multipartMap, multipartMultimap, path, path, path, pathMap, pathString, query, query, query, queryMap, queryMultimap, queryString, removeResponseHeaders, require, require, require, send, send, session, session, sessionOrNull, setPathMap, setResetHeadersOnError, setRoute, setUser, toString, upgrade
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
getContextPath, readOnly, websocket
public boolean isResponseStarted()
Context
isResponseStarted
in interface Context
isResponseStarted
in class ForwardingContext
@Nonnull public Context send(@Nonnull Path file)
Context
send
in interface Context
send
in class ForwardingContext
file
- File response.@Nonnull public Context send(@Nonnull byte[] data)
Context
send
in interface Context
send
in class ForwardingContext
data
- Response.@Nonnull public Context send(@Nonnull String data)
Context
send
in interface Context
send
in class ForwardingContext
data
- Response. Use UTF-8 charset.@Nonnull public Context send(@Nonnull ByteBuffer data)
Context
send
in interface Context
send
in class ForwardingContext
data
- Response.@Nonnull public Context send(@Nonnull FileChannel file)
Context
send
in interface Context
send
in class ForwardingContext
file
- File response.@Nonnull public Context send(@Nonnull AttachedFile file)
Context
send
in interface Context
send
in class ForwardingContext
file
- Attached file.@Nonnull public Context send(@Nonnull InputStream input)
Context
send
in interface Context
send
in class ForwardingContext
input
- Response.@Nonnull public Context send(@Nonnull StatusCode statusCode)
Context
send
in interface Context
send
in class ForwardingContext
statusCode
- Status code.@Nonnull public Context send(@Nonnull ReadableByteChannel channel)
Context
send
in interface Context
send
in class ForwardingContext
channel
- Response input.@Nonnull public Context send(@Nonnull String data, @Nonnull Charset charset)
Context
send
in interface Context
send
in class ForwardingContext
data
- Response.charset
- Charset.@Nonnull public Context sendError(@Nonnull Throwable cause)
Context
Router.errorCode(Throwable)
.sendError
in interface Context
sendError
in class ForwardingContext
cause
- Error. If this is a fatal error it is going to be rethrow it.@Nonnull public Context sendError(@Nonnull Throwable cause, @Nonnull StatusCode statusCode)
Context
sendError
in interface Context
sendError
in class ForwardingContext
cause
- Error. If this is a fatal error it is going to be rethrow it.statusCode
- Status code.@Nonnull public Context sendRedirect(@Nonnull String location)
Context
302
response.sendRedirect
in interface Context
sendRedirect
in class ForwardingContext
location
- Location.@Nonnull public Context sendRedirect(@Nonnull StatusCode redirect, @Nonnull String location)
Context
sendRedirect
in interface Context
sendRedirect
in class ForwardingContext
redirect
- Redirect status code.location
- Location.@Nonnull public Context render(@Nonnull Object value)
Context
render
in interface Context
render
in class ForwardingContext
value
- Object value.@Nonnull public Context responseStream(@Nonnull SneakyThrows.Consumer<OutputStream> consumer) throws Exception
Context
responseStream
in interface Context
responseStream
in class ForwardingContext
consumer
- Output stream consumer.Exception
- Is something goes wrong.@Nonnull public Context responseStream(@Nonnull MediaType contentType, @Nonnull SneakyThrows.Consumer<OutputStream> consumer) throws Exception
Context
responseStream
in interface Context
responseStream
in class ForwardingContext
contentType
- Content type.consumer
- Output stream consumer.Exception
- Is something goes wrong.@Nonnull public Context responseWriter(@Nonnull MediaType contentType, @Nonnull SneakyThrows.Consumer<PrintWriter> consumer) throws Exception
Context
responseWriter
in interface Context
responseWriter
in class ForwardingContext
contentType
- Content type.consumer
- Writer consumer.Exception
- Is something goes wrong.@Nonnull public Context responseWriter(@Nonnull SneakyThrows.Consumer<PrintWriter> consumer) throws Exception
Context
responseWriter
in interface Context
responseWriter
in class ForwardingContext
consumer
- Writer consumer.Exception
- Is something goes wrong.@Nonnull public Context responseWriter(@Nonnull MediaType contentType, @Nullable Charset charset, @Nonnull SneakyThrows.Consumer<PrintWriter> consumer) throws Exception
Context
responseWriter
in interface Context
responseWriter
in class ForwardingContext
contentType
- Content type.charset
- Charset.consumer
- Writer consumer.Exception
- Is something goes wrong.@Nonnull public OutputStream responseStream()
Context
responseStream
in interface Context
responseStream
in class ForwardingContext
@Nonnull public OutputStream responseStream(@Nonnull MediaType contentType)
Context
responseStream
in interface Context
responseStream
in class ForwardingContext
contentType
- Media type.@Nonnull public PrintWriter responseWriter()
Context
responseWriter
in interface Context
responseWriter
in class ForwardingContext
@Nonnull public PrintWriter responseWriter(@Nonnull MediaType contentType)
Context
responseWriter
in interface Context
responseWriter
in class ForwardingContext
contentType
- Content type.@Nonnull public PrintWriter responseWriter(@Nonnull MediaType contentType, @Nullable Charset charset)
Context
responseWriter
in interface Context
responseWriter
in class ForwardingContext
contentType
- Content type.charset
- Charset.@Nonnull public Sender responseSender()
Context
responseSender
in interface Context
responseSender
in class ForwardingContext
@Nonnull public Context removeResponseHeader(@Nonnull String name)
Context
removeResponseHeader
in interface Context
removeResponseHeader
in class ForwardingContext
name
- Header's name.@Nonnull public Context setResponseCookie(@Nonnull Cookie cookie)
Context
setResponseCookie
in interface Context
setResponseCookie
in class ForwardingContext
cookie
- Cookie to add.@Nonnull public Context setResponseHeader(@Nonnull String name, @Nonnull Date value)
Context
setResponseHeader
in interface Context
setResponseHeader
in class ForwardingContext
name
- Header name.value
- Header value.@Nonnull public Context setResponseCode(int statusCode)
Context
setResponseCode
in interface Context
setResponseCode
in class ForwardingContext
statusCode
- Status code.@Nonnull public Context setResponseCode(@Nonnull StatusCode statusCode)
Context
setResponseCode
in interface Context
setResponseCode
in class ForwardingContext
statusCode
- Status code.@Nonnull public Context setResponseHeader(@Nonnull String name, @Nonnull Object value)
Context
setResponseHeader
in interface Context
setResponseHeader
in class ForwardingContext
name
- Header name.value
- Header value.@Nonnull public Context setResponseHeader(@Nonnull String name, @Nonnull String value)
Context
setResponseHeader
in interface Context
setResponseHeader
in class ForwardingContext
name
- Header name.value
- Header value.@Nonnull public Context setResponseHeader(@Nonnull String name, @Nonnull Instant value)
Context
setResponseHeader
in interface Context
setResponseHeader
in class ForwardingContext
name
- Header name.value
- Header value.@Nonnull public Context setResponseLength(long length)
Context
setResponseLength
in interface Context
setResponseLength
in class ForwardingContext
length
- Response length.@Nonnull public Context setResponseType(@Nonnull String contentType)
Context
setResponseType
in interface Context
setResponseType
in class ForwardingContext
contentType
- Content type.@Nonnull public Context setResponseType(@Nonnull MediaType contentType)
Context
setResponseType
in interface Context
setResponseType
in class ForwardingContext
contentType
- Content type.@Nonnull public Context setResponseType(@Nonnull MediaType contentType, @Nullable Charset charset)
Context
setResponseType
in interface Context
setResponseType
in class ForwardingContext
contentType
- Content type.charset
- Charset.@Nonnull public Context setDefaultResponseType(@Nonnull MediaType contentType)
Context
setDefaultResponseType
in interface Context
setDefaultResponseType
in class ForwardingContext
contentType
- Content type.Copyright © 2019. All rights reserved.