/*
* Copyright 2014 Red Hat, Inc.
*
* Red Hat licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.vertx.reactivex.ext.web;
import io.vertx.reactivex.RxHelper;
import io.vertx.reactivex.ObservableHelper;
import io.vertx.reactivex.FlowableHelper;
import io.vertx.reactivex.impl.AsyncResultMaybe;
import io.vertx.reactivex.impl.AsyncResultSingle;
import io.vertx.reactivex.impl.AsyncResultCompletable;
import io.vertx.reactivex.WriteStreamObserver;
import io.vertx.reactivex.WriteStreamSubscriber;
import java.util.Map;
import java.util.Set;
import java.util.List;
import java.util.Iterator;
import java.util.function.Function;
import java.util.stream.Collectors;
import io.vertx.core.Handler;
import io.vertx.core.AsyncResult;
import io.vertx.core.json.JsonObject;
import io.vertx.core.json.JsonArray;
import io.vertx.lang.rx.RxGen;
import io.vertx.lang.rx.TypeArg;
import io.vertx.lang.rx.MappingIterator;
Represents the context for the handling of a request in Vert.x-Web.
A new instance is created for each HTTP request that is received in the Handler
of the router.
The same instance is passed to any matching request or failure handlers during the routing of the request or
failure.
The context provides access to the and
and allows you to maintain arbitrary data that lives for the lifetime of the context. Contexts are discarded once they
have been routed to the handler for the request.
The context also provides access to the Session
, cookies and body for the request, given the correct handlers in the application.
If you use the internal error handler
NOTE: This class has been automatically generated from the original
non RX-ified interface using Vert.x codegen. /**
* Represents the context for the handling of a request in Vert.x-Web.
* <p>
* A new instance is created for each HTTP request that is received in the
* {@link io.vertx.core.Handler} of the router.
* <p>
* The same instance is passed to any matching request or failure handlers during the routing of the request or
* failure.
* <p>
* The context provides access to the and
* and allows you to maintain arbitrary data that lives for the lifetime of the context. Contexts are discarded once they
* have been routed to the handler for the request.
* <p>
* The context also provides access to the {@link io.vertx.reactivex.ext.web.Session}, cookies and body for the request, given the correct handlers
* in the application.
* <p>
* If you use the internal error handler
*
* <p/>
* NOTE: This class has been automatically generated from the {@link io.vertx.ext.web.RoutingContext original} non RX-ified interface using Vert.x codegen.
*/
@RxGen(io.vertx.ext.web.RoutingContext.class)
public class RoutingContext {
@Override
public String toString() {
return delegate.toString();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
RoutingContext that = (RoutingContext) o;
return delegate.equals(that.delegate);
}
@Override
public int hashCode() {
return delegate.hashCode();
}
public static final TypeArg<RoutingContext> __TYPE_ARG = new TypeArg<>( obj -> new RoutingContext((io.vertx.ext.web.RoutingContext) obj),
RoutingContext::getDelegate
);
private final io.vertx.ext.web.RoutingContext delegate;
public RoutingContext(io.vertx.ext.web.RoutingContext delegate) {
this.delegate = delegate;
}
public RoutingContext(Object delegate) {
this.delegate = (io.vertx.ext.web.RoutingContext)delegate;
}
public io.vertx.ext.web.RoutingContext getDelegate() {
return delegate;
}
private static final TypeArg<io.vertx.reactivex.core.http.Cookie> TYPE_ARG_0 = new TypeArg<io.vertx.reactivex.core.http.Cookie>(o1 -> io.vertx.reactivex.core.http.Cookie.newInstance((io.vertx.core.http.Cookie)o1), o1 -> o1.getDelegate());
private static final TypeArg<io.vertx.reactivex.ext.web.FileUpload> TYPE_ARG_1 = new TypeArg<io.vertx.reactivex.ext.web.FileUpload>(o1 -> io.vertx.reactivex.ext.web.FileUpload.newInstance((io.vertx.ext.web.FileUpload)o1), o1 -> o1.getDelegate());
private static final TypeArg<io.vertx.reactivex.ext.web.LanguageHeader> TYPE_ARG_2 = new TypeArg<io.vertx.reactivex.ext.web.LanguageHeader>(o1 -> io.vertx.reactivex.ext.web.LanguageHeader.newInstance((io.vertx.ext.web.LanguageHeader)o1), o1 -> o1.getDelegate());
Returns: the HTTP request object
/**
* @return the HTTP request object
*/
public io.vertx.reactivex.core.http.HttpServerRequest request() {
if (cached_0 != null) {
return cached_0;
}
io.vertx.reactivex.core.http.HttpServerRequest ret = io.vertx.reactivex.core.http.HttpServerRequest.newInstance((io.vertx.core.http.HttpServerRequest)delegate.request());
cached_0 = ret;
return ret;
}
Returns: the HTTP response object
/**
* @return the HTTP response object
*/
public io.vertx.reactivex.core.http.HttpServerResponse response() {
if (cached_1 != null) {
return cached_1;
}
io.vertx.reactivex.core.http.HttpServerResponse ret = io.vertx.reactivex.core.http.HttpServerResponse.newInstance((io.vertx.core.http.HttpServerResponse)delegate.response());
cached_1 = ret;
return ret;
}
Tell the router to route this context to the next matching route (if any).
This method, if called, does not need to be called during the execution of the handler, it can be called
some arbitrary time later, if required.
If next is not called for a handler then the handler should make sure it ends the response or no response
will be sent.
/**
* Tell the router to route this context to the next matching route (if any).
* This method, if called, does not need to be called during the execution of the handler, it can be called
* some arbitrary time later, if required.
* <p>
* If next is not called for a handler then the handler should make sure it ends the response or no response
* will be sent.
*/
public void next() {
delegate.next();
}
Fail the context with the specified status code.
This will cause the router to route the context to any matching failure handlers for the request. If no failure handlers match It will trigger the error handler matching the status code. You can define such error handler with Router.errorHandler
. If no error handler is not defined, It will send a default failure response with provided status code.
Params: - statusCode – the HTTP status code
/**
* Fail the context with the specified status code.
* <p>
* This will cause the router to route the context to any matching failure handlers for the request. If no failure handlers
* match It will trigger the error handler matching the status code. You can define such error handler with
* {@link io.vertx.reactivex.ext.web.Router#errorHandler}. If no error handler is not defined, It will send a default failure response with provided status code.
* @param statusCode the HTTP status code
*/
public void fail(int statusCode) {
delegate.fail(statusCode);
}
Fail the context with the specified throwable and 500 status code.
This will cause the router to route the context to any matching failure handlers for the request. If no failure handlers match It will trigger the error handler matching the status code. You can define such error handler with Router.errorHandler
. If no error handler is not defined, It will send a default failure response with 500 status code.
Params: - throwable – a throwable representing the failure
/**
* Fail the context with the specified throwable and 500 status code.
* <p>
* This will cause the router to route the context to any matching failure handlers for the request. If no failure handlers
* match It will trigger the error handler matching the status code. You can define such error handler with
* {@link io.vertx.reactivex.ext.web.Router#errorHandler}. If no error handler is not defined, It will send a default failure response with 500 status code.
* @param throwable a throwable representing the failure
*/
public void fail(java.lang.Throwable throwable) {
delegate.fail(throwable);
}
Fail the context with the specified throwable and the specified the status code.
This will cause the router to route the context to any matching failure handlers for the request. If no failure handlers match It will trigger the error handler matching the status code. You can define such error handler with Router.errorHandler
. If no error handler is not defined, It will send a default failure response with provided status code.
Params: - statusCode – the HTTP status code
- throwable – a throwable representing the failure
/**
* Fail the context with the specified throwable and the specified the status code.
* <p>
* This will cause the router to route the context to any matching failure handlers for the request. If no failure handlers
* match It will trigger the error handler matching the status code. You can define such error handler with
* {@link io.vertx.reactivex.ext.web.Router#errorHandler}. If no error handler is not defined, It will send a default failure response with provided status code.
* @param statusCode the HTTP status code
* @param throwable a throwable representing the failure
*/
public void fail(int statusCode, java.lang.Throwable throwable) {
delegate.fail(statusCode, throwable);
}
Put some arbitrary data in the context. This will be available in any handlers that receive the context.
Params: - key – the key for the data
- obj – the data
Returns: a reference to this, so the API can be used fluently
/**
* Put some arbitrary data in the context. This will be available in any handlers that receive the context.
* @param key the key for the data
* @param obj the data
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.reactivex.ext.web.RoutingContext put(String key, java.lang.Object obj) {
delegate.put(key, obj);
return this;
}
Get some data from the context. The data is available in any handlers that receive the context.
Params: - key – the key for the data
Returns: the data
/**
* Get some data from the context. The data is available in any handlers that receive the context.
* @param key the key for the data
* @return the data
*/
public <T> T get(String key) {
T ret = (T) delegate.get(key);
return ret;
}
Remove some data from the context. The data is available in any handlers that receive the context.
Params: - key – the key for the data
Returns: the previous data associated with the key
/**
* Remove some data from the context. The data is available in any handlers that receive the context.
* @param key the key for the data
* @return the previous data associated with the key
*/
public <T> T remove(String key) {
T ret = (T) delegate.remove(key);
return ret;
}
Returns: the Vert.x instance associated to the initiating Router
for this context
/**
* @return the Vert.x instance associated to the initiating {@link io.vertx.reactivex.ext.web.Router} for this context
*/
public io.vertx.reactivex.core.Vertx vertx() {
if (cached_2 != null) {
return cached_2;
}
io.vertx.reactivex.core.Vertx ret = io.vertx.reactivex.core.Vertx.newInstance((io.vertx.core.Vertx)delegate.vertx());
cached_2 = ret;
return ret;
}
Returns: the mount point for this router. It will be null for a top level router. For a sub-router it will be the path at which the subrouter was mounted.
/**
* @return the mount point for this router. It will be null for a top level router. For a sub-router it will be the path at which the subrouter was mounted.
*/
public String mountPoint() {
String ret = delegate.mountPoint();
return ret;
}
Returns: the current route this context is being routed through.
/**
* @return the current route this context is being routed through.
*/
public io.vertx.reactivex.ext.web.Route currentRoute() {
io.vertx.reactivex.ext.web.Route ret = io.vertx.reactivex.ext.web.Route.newInstance((io.vertx.ext.web.Route)delegate.currentRoute());
return ret;
}
Use normalizedPath
instead Returns:
/**
* Use {@link io.vertx.reactivex.ext.web.RoutingContext#normalizedPath} instead
* @return
*/
@Deprecated()
public String normalisedPath() {
String ret = delegate.normalisedPath();
return ret;
}
Return the normalized path for the request.
The normalized path is where the URI path has been decoded, i.e. any unicode or other illegal URL characters that
were encoded in the original URL with `%` will be returned to their original form. E.g. `%20` will revert to a space.
Also `+` reverts to a space in a query.
The normalized path will also not contain any `..` character sequences to prevent resources being accessed outside
of the permitted area.
It's recommended to always use the normalized path as opposed to
if accessing server resources requested by a client.
Returns: the normalized path
/**
* Return the normalized path for the request.
* <p>
* The normalized path is where the URI path has been decoded, i.e. any unicode or other illegal URL characters that
* were encoded in the original URL with `%` will be returned to their original form. E.g. `%20` will revert to a space.
* Also `+` reverts to a space in a query.
* <p>
* The normalized path will also not contain any `..` character sequences to prevent resources being accessed outside
* of the permitted area.
* <p>
* It's recommended to always use the normalized path as opposed to
* if accessing server resources requested by a client.
* @return the normalized path
*/
public String normalizedPath() {
String ret = delegate.normalizedPath();
return ret;
}
Get the cookie with the specified name.
Params: - name – the cookie name
Returns: the cookie
/**
* Get the cookie with the specified name.
* @param name the cookie name
* @return the cookie
*/
public io.vertx.reactivex.core.http.Cookie getCookie(String name) {
io.vertx.reactivex.core.http.Cookie ret = io.vertx.reactivex.core.http.Cookie.newInstance((io.vertx.core.http.Cookie)delegate.getCookie(name));
return ret;
}
Add a cookie. This will be sent back to the client in the response.
Params: - cookie – the cookie
Returns: a reference to this, so the API can be used fluently
/**
* Add a cookie. This will be sent back to the client in the response.
* @param cookie the cookie
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.reactivex.ext.web.RoutingContext addCookie(io.vertx.reactivex.core.http.Cookie cookie) {
delegate.addCookie(cookie.getDelegate());
return this;
}
Expire a cookie, notifying a User Agent to remove it from its cookie jar.
Params: - name – the name of the cookie
Returns: the cookie, if it existed, or null
/**
* Expire a cookie, notifying a User Agent to remove it from its cookie jar.
* @param name the name of the cookie
* @return the cookie, if it existed, or null
*/
public io.vertx.reactivex.core.http.Cookie removeCookie(String name) {
io.vertx.reactivex.core.http.Cookie ret = io.vertx.reactivex.core.http.Cookie.newInstance((io.vertx.core.http.Cookie)delegate.removeCookie(name));
return ret;
}
Remove a cookie from the cookie set. If invalidate is true then it will expire a cookie, notifying a User Agent to
remove it from its cookie jar.
Params: - name – the name of the cookie
- invalidate –
Returns: the cookie, if it existed, or null
/**
* Remove a cookie from the cookie set. If invalidate is true then it will expire a cookie, notifying a User Agent to
* remove it from its cookie jar.
* @param name the name of the cookie
* @param invalidate
* @return the cookie, if it existed, or null
*/
public io.vertx.reactivex.core.http.Cookie removeCookie(String name, boolean invalidate) {
io.vertx.reactivex.core.http.Cookie ret = io.vertx.reactivex.core.http.Cookie.newInstance((io.vertx.core.http.Cookie)delegate.removeCookie(name, invalidate));
return ret;
}
Returns: the number of cookies.
/**
* @return the number of cookies.
*/
public int cookieCount() {
int ret = delegate.cookieCount();
return ret;
}
Returns: a map of all the cookies.
/**
* @return a map of all the cookies.
*/
public java.util.Map<String, io.vertx.reactivex.core.http.Cookie> cookieMap() {
java.util.Map<String, io.vertx.reactivex.core.http.Cookie> ret = delegate.cookieMap().entrySet().stream().collect(Collectors.toMap(_e -> _e.getKey(), _e -> io.vertx.reactivex.core.http.Cookie.newInstance((io.vertx.core.http.Cookie)_e.getValue())));
return ret;
}
Returns: the entire HTTP request body as a string, assuming UTF-8 encoding if the request does not provide the content type charset attribute. If a charset is provided in the request that it shall be respected. The context must have first been routed to a BodyHandler
for this to be populated.
/**
* @return the entire HTTP request body as a string, assuming UTF-8 encoding if the request does not provide the content type charset attribute. If a charset is provided in the request that it shall be respected. The context must have first been routed to a {@link io.vertx.reactivex.ext.web.handler.BodyHandler} for this to be populated.
*/
public String getBodyAsString() {
String ret = delegate.getBodyAsString();
return ret;
}
Get the entire HTTP request body as a string, assuming the specified encoding. The context must have first been routed to a BodyHandler
for this to be populated. Params: - encoding – the encoding, e.g. "UTF-16"
Returns: the body
/**
* Get the entire HTTP request body as a string, assuming the specified encoding. The context must have first been routed to a
* {@link io.vertx.reactivex.ext.web.handler.BodyHandler} for this to be populated.
* @param encoding the encoding, e.g. "UTF-16"
* @return the body
*/
public String getBodyAsString(String encoding) {
String ret = delegate.getBodyAsString(encoding);
return ret;
}
Gets the current body buffer as a . If a positive limit is provided the parsing will only happen if the buffer length is smaller or equal to the limit. Otherwise an IllegalStateException
is thrown. When the application is only handling uploads in JSON format, it is recommended to set a limit on BodyHandler.setBodyLimit
as this will avoid the upload to be parsed and loaded into the application memory. Params: - maxAllowedLength – if the current buffer length is greater than the limit an
IllegalStateException
is thrown. This can be used to avoid DDoS attacks on very long JSON payloads that could take over the CPU while attempting to parse the data.
Returns: Get the entire HTTP request body as a . The context must have first been routed to a BodyHandler
for this to be populated.
When the body is null
or the "null"
JSON literal then null
is returned.
/**
* Gets the current body buffer as a . If a positive limit is provided the parsing will only happen
* if the buffer length is smaller or equal to the limit. Otherwise an {@link java.lang.IllegalStateException} is thrown.
*
* When the application is only handling uploads in JSON format, it is recommended to set a limit on
* {@link io.vertx.reactivex.ext.web.handler.BodyHandler#setBodyLimit} as this will avoid the upload to be parsed and
* loaded into the application memory.
* @param maxAllowedLength if the current buffer length is greater than the limit an {@link java.lang.IllegalStateException} is thrown. This can be used to avoid DDoS attacks on very long JSON payloads that could take over the CPU while attempting to parse the data.
* @return Get the entire HTTP request body as a . The context must have first been routed to a {@link io.vertx.reactivex.ext.web.handler.BodyHandler} for this to be populated. <br/> When the body is <code>null</code> or the <code>"null"</code> JSON literal then <code>null</code> is returned.
*/
public JsonObject getBodyAsJson(int maxAllowedLength) {
JsonObject ret = delegate.getBodyAsJson(maxAllowedLength);
return ret;
}
Gets the current body buffer as a . If a positive limit is provided the parsing will only happen if the buffer length is smaller or equal to the limit. Otherwise an IllegalStateException
is thrown. When the application is only handling uploads in JSON format, it is recommended to set a limit on BodyHandler.setBodyLimit
as this will avoid the upload to be parsed and loaded into the application memory. Params: - maxAllowedLength – if the current buffer length is greater than the limit an
IllegalStateException
is thrown. This can be used to avoid DDoS attacks on very long JSON payloads that could take over the CPU while attempting to parse the data.
Returns: Get the entire HTTP request body as a . The context must have first been routed to a BodyHandler
for this to be populated.
When the body is null
or the "null"
JSON literal then null
is returned.
/**
* Gets the current body buffer as a . If a positive limit is provided the parsing will only happen
* if the buffer length is smaller or equal to the limit. Otherwise an {@link java.lang.IllegalStateException} is thrown.
*
* When the application is only handling uploads in JSON format, it is recommended to set a limit on
* {@link io.vertx.reactivex.ext.web.handler.BodyHandler#setBodyLimit} as this will avoid the upload to be parsed and
* loaded into the application memory.
* @param maxAllowedLength if the current buffer length is greater than the limit an {@link java.lang.IllegalStateException} is thrown. This can be used to avoid DDoS attacks on very long JSON payloads that could take over the CPU while attempting to parse the data.
* @return Get the entire HTTP request body as a . The context must have first been routed to a {@link io.vertx.reactivex.ext.web.handler.BodyHandler} for this to be populated. <br/> When the body is <code>null</code> or the <code>"null"</code> JSON literal then <code>null</code> is returned.
*/
public JsonArray getBodyAsJsonArray(int maxAllowedLength) {
JsonArray ret = delegate.getBodyAsJsonArray(maxAllowedLength);
return ret;
}
Returns: Get the entire HTTP request body as a . The context must have first been routed to a BodyHandler
for this to be populated.
When the body is null
or the "null"
JSON literal then null
is returned.
/**
* @return Get the entire HTTP request body as a . The context must have first been routed to a {@link io.vertx.reactivex.ext.web.handler.BodyHandler} for this to be populated. <br/> When the body is <code>null</code> or the <code>"null"</code> JSON literal then <code>null</code> is returned.
*/
public JsonObject getBodyAsJson() {
JsonObject ret = delegate.getBodyAsJson();
return ret;
}
Returns: Get the entire HTTP request body as a . The context must have first been routed to a BodyHandler
for this to be populated.
When the body is null
or the "null"
JSON literal then null
is returned.
/**
* @return Get the entire HTTP request body as a . The context must have first been routed to a {@link io.vertx.reactivex.ext.web.handler.BodyHandler} for this to be populated. <br/> When the body is <code>null</code> or the <code>"null"</code> JSON literal then <code>null</code> is returned.
*/
public JsonArray getBodyAsJsonArray() {
JsonArray ret = delegate.getBodyAsJsonArray();
return ret;
}
Returns: Get the entire HTTP request body as a . The context must have first been routed to a BodyHandler
for this to be populated.
/**
* @return Get the entire HTTP request body as a . The context must have first been routed to a {@link io.vertx.reactivex.ext.web.handler.BodyHandler} for this to be populated.
*/
public io.vertx.reactivex.core.buffer.Buffer getBody() {
io.vertx.reactivex.core.buffer.Buffer ret = io.vertx.reactivex.core.buffer.Buffer.newInstance((io.vertx.core.buffer.Buffer)delegate.getBody());
return ret;
}
Returns: a set of fileuploads (if any) for the request. The context must have first been routed to a BodyHandler
for this to work.
/**
* @return a set of fileuploads (if any) for the request. The context must have first been routed to a {@link io.vertx.reactivex.ext.web.handler.BodyHandler} for this to work.
*/
public Set<io.vertx.reactivex.ext.web.FileUpload> fileUploads() {
Set<io.vertx.reactivex.ext.web.FileUpload> ret = delegate.fileUploads().stream().map(elt -> io.vertx.reactivex.ext.web.FileUpload.newInstance((io.vertx.ext.web.FileUpload)elt)).collect(Collectors.toSet());
return ret;
}
Get the session. The context must have first been routed to a SessionHandler
for this to be populated. Sessions live for a browser session, and are maintained by session cookies. Returns: the session.
/**
* Get the session. The context must have first been routed to a {@link io.vertx.reactivex.ext.web.handler.SessionHandler}
* for this to be populated.
* Sessions live for a browser session, and are maintained by session cookies.
* @return the session.
*/
public io.vertx.reactivex.ext.web.Session session() {
io.vertx.reactivex.ext.web.Session ret = io.vertx.reactivex.ext.web.Session.newInstance((io.vertx.ext.web.Session)delegate.session());
return ret;
}
Whether the session
has been already called or not. This is usually used by the SessionHandler
. Returns: true if the session has been accessed.
/**
* Whether the {@link io.vertx.reactivex.ext.web.RoutingContext#session} has been already called or not. This is usually used by the
* {@link io.vertx.reactivex.ext.web.handler.SessionHandler}.
* @return true if the session has been accessed.
*/
public boolean isSessionAccessed() {
boolean ret = delegate.isSessionAccessed();
return ret;
}
Get the authenticated user (if any). This will usually be injected by an auth handler if authentication if successful.
Returns: the user, or null if the current user is not authenticated.
/**
* Get the authenticated user (if any). This will usually be injected by an auth handler if authentication if successful.
* @return the user, or null if the current user is not authenticated.
*/
public io.vertx.reactivex.ext.auth.User user() {
io.vertx.reactivex.ext.auth.User ret = io.vertx.reactivex.ext.auth.User.newInstance((io.vertx.ext.auth.User)delegate.user());
return ret;
}
If the context is being routed to failure handlers after a failure has been triggered by calling fail
then this will return that throwable. It can be used by failure handlers to render a response, e.g. create a failure response page. Returns: the throwable used when signalling failure
/**
* If the context is being routed to failure handlers after a failure has been triggered by calling
* {@link io.vertx.reactivex.ext.web.RoutingContext#fail} then this will return that throwable. It can be used by failure handlers to render a response,
* e.g. create a failure response page.
* @return the throwable used when signalling failure
*/
public java.lang.Throwable failure() {
if (cached_3 != null) {
return cached_3;
}
java.lang.Throwable ret = delegate.failure();
cached_3 = ret;
return ret;
}
If the context is being routed to failure handlers after a failure has been triggered by calling fail
then this will return that status code. It can be used by failure handlers to render a response, e.g. create a failure response page. When the status code has not been set yet (it is undefined) its value will be -1. Returns: the status code used when signalling failure
/**
* If the context is being routed to failure handlers after a failure has been triggered by calling
* {@link io.vertx.reactivex.ext.web.RoutingContext#fail} then this will return that status code. It can be used by failure handlers to render a response,
* e.g. create a failure response page.
*
* When the status code has not been set yet (it is undefined) its value will be -1.
* @return the status code used when signalling failure
*/
public int statusCode() {
if (cached_4 != null) {
return cached_4;
}
int ret = delegate.statusCode();
cached_4 = ret;
return ret;
}
If the route specifies produces matches, e.g. produces `text/html` and `text/plain`, and the `accept` header
matches one or more of these then this returns the most acceptable match.
Returns: the most acceptable content type.
/**
* If the route specifies produces matches, e.g. produces `text/html` and `text/plain`, and the `accept` header
* matches one or more of these then this returns the most acceptable match.
* @return the most acceptable content type.
*/
public String getAcceptableContentType() {
String ret = delegate.getAcceptableContentType();
return ret;
}
The headers:
- Accept
- Accept-Charset
- Accept-Encoding
- Accept-Language
- Content-Type
Parsed into ParsedHeaderValue
Returns: A container with the parsed headers.
/**
* The headers:
* <ol>
* <li>Accept</li>
* <li>Accept-Charset</li>
* <li>Accept-Encoding</li>
* <li>Accept-Language</li>
* <li>Content-Type</li>
* </ol>
* Parsed into {@link io.vertx.reactivex.ext.web.ParsedHeaderValue}
* @return A container with the parsed headers.
*/
public io.vertx.reactivex.ext.web.ParsedHeaderValues parsedHeaders() {
if (cached_5 != null) {
return cached_5;
}
io.vertx.reactivex.ext.web.ParsedHeaderValues ret = io.vertx.reactivex.ext.web.ParsedHeaderValues.newInstance((io.vertx.ext.web.ParsedHeaderValues)delegate.parsedHeaders());
cached_5 = ret;
return ret;
}
Add a handler that will be called just before headers are written to the response. This gives you a hook where
you can write any extra headers before the response has been written when it will be too late.
Params: - handler – the handler
Returns: the id of the handler. This can be used if you later want to remove the handler.
/**
* Add a handler that will be called just before headers are written to the response. This gives you a hook where
* you can write any extra headers before the response has been written when it will be too late.
* @param handler the handler
* @return the id of the handler. This can be used if you later want to remove the handler.
*/
public int addHeadersEndHandler(Handler<Void> handler) {
int ret = delegate.addHeadersEndHandler(handler);
return ret;
}
Remove a headers end handler
Params: - handlerID – the id as returned from
addHeadersEndHandler
.
Returns: true if the handler existed and was removed, false otherwise
/**
* Remove a headers end handler
* @param handlerID the id as returned from {@link io.vertx.reactivex.ext.web.RoutingContext#addHeadersEndHandler}.
* @return true if the handler existed and was removed, false otherwise
*/
public boolean removeHeadersEndHandler(int handlerID) {
boolean ret = delegate.removeHeadersEndHandler(handlerID);
return ret;
}
Provides a handler that will be called after the last part of the body is written to the wire.
The handler is called asynchronously of when the response has been received by the client.
This provides a hook allowing you to do more operations once the request has been sent over the wire.
Do not use this for resource cleanup as this handler might never get called (e.g. if the connection is reset).
Params: - handler – the handler
Returns: the id of the handler. This can be used if you later want to remove the handler.
/**
* Provides a handler that will be called after the last part of the body is written to the wire.
* The handler is called asynchronously of when the response has been received by the client.
* This provides a hook allowing you to do more operations once the request has been sent over the wire.
* Do not use this for resource cleanup as this handler might never get called (e.g. if the connection is reset).
* @param handler the handler
* @return the id of the handler. This can be used if you later want to remove the handler.
*/
public int addBodyEndHandler(Handler<Void> handler) {
int ret = delegate.addBodyEndHandler(handler);
return ret;
}
Remove a body end handler
Params: - handlerID – the id as returned from
addBodyEndHandler
.
Returns: true if the handler existed and was removed, false otherwise
/**
* Remove a body end handler
* @param handlerID the id as returned from {@link io.vertx.reactivex.ext.web.RoutingContext#addBodyEndHandler}.
* @return true if the handler existed and was removed, false otherwise
*/
public boolean removeBodyEndHandler(int handlerID) {
boolean ret = delegate.removeBodyEndHandler(handlerID);
return ret;
}
Add an end handler for the request/response context. This will be called when the response is disposed or an
exception has been encountered to allow consistent cleanup. The handler is called asynchronously of when the
response has been received by the client.
Params: - handler – the handler that will be called with either a success or failure result.
Returns: the id of the handler. This can be used if you later want to remove the handler.
/**
* Add an end handler for the request/response context. This will be called when the response is disposed or an
* exception has been encountered to allow consistent cleanup. The handler is called asynchronously of when the
* response has been received by the client.
* @param handler the handler that will be called with either a success or failure result.
* @return the id of the handler. This can be used if you later want to remove the handler.
*/
public int addEndHandler(Handler<AsyncResult<Void>> handler) {
int ret = delegate.addEndHandler(handler);
return ret;
}
Remove an end handler
Params: - handlerID – the id as returned from
addEndHandler
.
Returns: true if the handler existed and was removed, false otherwise
/**
* Remove an end handler
* @param handlerID the id as returned from {@link io.vertx.reactivex.ext.web.RoutingContext#addEndHandler}.
* @return true if the handler existed and was removed, false otherwise
*/
public boolean removeEndHandler(int handlerID) {
boolean ret = delegate.removeEndHandler(handlerID);
return ret;
}
Returns: true if the context is being routed to failure handlers.
/**
* @return true if the context is being routed to failure handlers.
*/
public boolean failed() {
boolean ret = delegate.failed();
return ret;
}
Set the body. Used by the BodyHandler
. You will not normally call this method. Params: - body – the body
/**
* Set the body. Used by the {@link io.vertx.reactivex.ext.web.handler.BodyHandler}. You will not normally call this method.
* @param body the body
*/
public void setBody(io.vertx.reactivex.core.buffer.Buffer body) {
delegate.setBody(body.getDelegate());
}
Set the session. Used by the SessionHandler
. You will not normally call this method. Params: - session – the session
/**
* Set the session. Used by the {@link io.vertx.reactivex.ext.web.handler.SessionHandler}. You will not normally call this method.
* @param session the session
*/
public void setSession(io.vertx.reactivex.ext.web.Session session) {
delegate.setSession(session.getDelegate());
}
Set the user. Usually used by auth handlers to inject a User. You will not normally call this method.
Params: - user – the user
/**
* Set the user. Usually used by auth handlers to inject a User. You will not normally call this method.
* @param user the user
*/
public void setUser(io.vertx.reactivex.ext.auth.User user) {
delegate.setUser(user.getDelegate());
}
Clear the current user object in the context. This usually is used for implementing a log out feature, since the
current user is unbounded from the routing context.
/**
* Clear the current user object in the context. This usually is used for implementing a log out feature, since the
* current user is unbounded from the routing context.
*/
public void clearUser() {
delegate.clearUser();
}
Set the acceptable content type. Used by
Params: - contentType – the content type
/**
* Set the acceptable content type. Used by
* @param contentType the content type
*/
public void setAcceptableContentType(String contentType) {
delegate.setAcceptableContentType(contentType);
}
Restarts the current router with a new path and reusing the original method. All path parameters are then parsed
and available on the params list. Query params will also be allowed and available.
Params: - path – the new http path.
/**
* Restarts the current router with a new path and reusing the original method. All path parameters are then parsed
* and available on the params list. Query params will also be allowed and available.
* @param path the new http path.
*/
public void reroute(String path) {
delegate.reroute(path);
}
Restarts the current router with a new method and path. All path parameters are then parsed and available on the
params list. Query params will also be allowed and available.
Params: - method – the new http request
- path – the new http path.
/**
* Restarts the current router with a new method and path. All path parameters are then parsed and available on the
* params list. Query params will also be allowed and available.
* @param method the new http request
* @param path the new http path.
*/
public void reroute(io.vertx.core.http.HttpMethod method, String path) {
delegate.reroute(method, path);
}
Returns the languages for the current request. The languages are determined from the Accept-Language
header and sorted on quality.
When 2 or more entries have the same quality then the order used to return the best match is based on the lowest
index on the original list. For example if a user has en-US and en-GB with same quality and this order the best
match will be en-US because it was declared as first entry by the client.
Returns: The best matched language for the request
/**
* Returns the languages for the current request. The languages are determined from the <code>Accept-Language</code>
* header and sorted on quality.
*
* When 2 or more entries have the same quality then the order used to return the best match is based on the lowest
* index on the original list. For example if a user has en-US and en-GB with same quality and this order the best
* match will be en-US because it was declared as first entry by the client.
* @return The best matched language for the request
*/
public List<io.vertx.reactivex.ext.web.LanguageHeader> acceptableLanguages() {
if (cached_6 != null) {
return cached_6;
}
List<io.vertx.reactivex.ext.web.LanguageHeader> ret = delegate.acceptableLanguages().stream().map(elt -> io.vertx.reactivex.ext.web.LanguageHeader.newInstance((io.vertx.ext.web.LanguageHeader)elt)).collect(Collectors.toList());
cached_6 = ret;
return ret;
}
Helper to return the user preferred language.
It is the same action as returning the first element of the acceptable languages.
Returns: the users preferred locale.
/**
* Helper to return the user preferred language.
* It is the same action as returning the first element of the acceptable languages.
* @return the users preferred locale.
*/
public io.vertx.reactivex.ext.web.LanguageHeader preferredLanguage() {
if (cached_7 != null) {
return cached_7;
}
io.vertx.reactivex.ext.web.LanguageHeader ret = io.vertx.reactivex.ext.web.LanguageHeader.newInstance((io.vertx.ext.web.LanguageHeader)delegate.preferredLanguage());
cached_7 = ret;
return ret;
}
Returns a map of named parameters as defined in path declaration with their actual values
Returns: the map of named parameters
/**
* Returns a map of named parameters as defined in path declaration with their actual values
* @return the map of named parameters
*/
public java.util.Map<String, String> pathParams() {
java.util.Map<String, String> ret = delegate.pathParams();
return ret;
}
Gets the value of a single path parameter
Params: - name – the name of parameter as defined in path declaration
Returns: the actual value of the parameter or null if it doesn't exist
/**
* Gets the value of a single path parameter
* @param name the name of parameter as defined in path declaration
* @return the actual value of the parameter or null if it doesn't exist
*/
public String pathParam(String name) {
String ret = delegate.pathParam(name);
return ret;
}
Returns a map of all query parameters inside the query string
The query parameters are lazily decoded: the decoding happens on the first time this method is called. If the query string is invalid
it fails the context
Returns: the multimap of query parameters
/**
* Returns a map of all query parameters inside the <a href="https://en.wikipedia.org/wiki/Query_string">query string</a><br/>
* The query parameters are lazily decoded: the decoding happens on the first time this method is called. If the query string is invalid
* it fails the context
* @return the multimap of query parameters
*/
public io.vertx.reactivex.core.MultiMap queryParams() {
io.vertx.reactivex.core.MultiMap ret = io.vertx.reactivex.core.MultiMap.newInstance((io.vertx.core.MultiMap)delegate.queryParams());
return ret;
}
Gets the value of a single query parameter. For more info queryParams
Params: - name – The name of query parameter
Returns: The list of all parameters matching the parameter name. It returns an empty list if no query parameter with name
was found
/**
* Gets the value of a single query parameter. For more info {@link io.vertx.reactivex.ext.web.RoutingContext#queryParams}
* @param name The name of query parameter
* @return The list of all parameters matching the parameter name. It returns an empty list if no query parameter with <code>name</code> was found
*/
public List<String> queryParam(String name) {
List<String> ret = delegate.queryParam(name);
return ret;
}
Set Content-Disposition get to "attachment" with optional filename
mime type.
Params: - filename – the filename for the attachment
Returns:
/**
* Set Content-Disposition get to "attachment" with optional <code>filename</code> mime type.
* @param filename the filename for the attachment
* @return
*/
public io.vertx.reactivex.ext.web.RoutingContext attachment(String filename) {
delegate.attachment(filename);
return this;
}
See redirect
. Params: - url –
- handler –
Returns:
/**
* See {@link io.vertx.reactivex.ext.web.RoutingContext#redirect}.
* @param url
* @param handler
* @return
*/
public io.vertx.reactivex.ext.web.RoutingContext redirect(String url, Handler<AsyncResult<Void>> handler) {
delegate.redirect(url, handler);
return this;
}
See redirect
. Params: - url –
Returns:
/**
* See {@link io.vertx.reactivex.ext.web.RoutingContext#redirect}.
* @param url
* @return
*/
public io.vertx.reactivex.ext.web.RoutingContext redirect(String url) {
return
redirect(url, ar -> { });
}
See redirect
. Params: - url –
Returns:
/**
* See {@link io.vertx.reactivex.ext.web.RoutingContext#redirect}.
* @param url
* @return
*/
public io.reactivex.Completable rxRedirect(String url) {
return AsyncResultCompletable.toCompletable($handler -> {
redirect(url, $handler);
});
}
See json
. Params: - json –
- handler –
Returns:
/**
* See {@link io.vertx.reactivex.ext.web.RoutingContext#json}.
* @param json
* @param handler
* @return
*/
public io.vertx.reactivex.ext.web.RoutingContext json(java.lang.Object json, Handler<AsyncResult<Void>> handler) {
delegate.json(json, handler);
return this;
}
See json
. Params: - json –
Returns:
/**
* See {@link io.vertx.reactivex.ext.web.RoutingContext#json}.
* @param json
* @return
*/
public io.vertx.reactivex.ext.web.RoutingContext json(java.lang.Object json) {
return
json(json, ar -> { });
}
See json
. Params: - json –
Returns:
/**
* See {@link io.vertx.reactivex.ext.web.RoutingContext#json}.
* @param json
* @return
*/
public io.reactivex.Completable rxJson(java.lang.Object json) {
return AsyncResultCompletable.toCompletable($handler -> {
json(json, $handler);
});
}
Check if the incoming request contains the "Content-Type"
get field, and it contains the give mime `type`.
If there is no request body, `false` is returned.
If there is no content type, `false` is returned.
Otherwise, it returns true if the `type` that matches.
Examples:
// With Content-Type: text/html; charset=utf-8
is("html"); // => true
is("text/html"); // => true
// When Content-Type is application/json
is("application/json"); // => true
is("html"); // => false
Params: - type – content type
Returns: The most close value
/**
* Check if the incoming request contains the "Content-Type"
* get field, and it contains the give mime `type`.
* If there is no request body, `false` is returned.
* If there is no content type, `false` is returned.
* Otherwise, it returns true if the `type` that matches.
* <p/>
* Examples:
* <p/>
* // With Content-Type: text/html; charset=utf-8
* is("html"); // => true
* is("text/html"); // => true
* <p/>
* // When Content-Type is application/json
* is("application/json"); // => true
* is("html"); // => false
* @param type content type
* @return The most close value
*/
public boolean is(String type) {
if (cached_8 != null) {
return cached_8;
}
boolean ret = delegate.is(type);
cached_8 = ret;
return ret;
}
Check if the request is fresh, aka
Last-Modified and/or the ETag
still match.
Returns: true if content is fresh according to the cache.
/**
* Check if the request is fresh, aka
* Last-Modified and/or the ETag
* still match.
* @return true if content is fresh according to the cache.
*/
public boolean isFresh() {
boolean ret = delegate.isFresh();
return ret;
}
Set the ETag of a response.
This will normalize the quotes if necessary.
etag('md5hashsum');
etag('"md5hashsum"');
('W/"123456789"');
Params: - etag – the etag value
Returns:
/**
* Set the ETag of a response.
* This will normalize the quotes if necessary.
* <p/>
* etag('md5hashsum');
* etag('"md5hashsum"');
* ('W/"123456789"');
* @param etag the etag value
* @return
*/
public io.vertx.reactivex.ext.web.RoutingContext etag(String etag) {
delegate.etag(etag);
return this;
}
Set the Last-Modified date using a String.
Params: - instant – the last modified instant
Returns:
/**
* Set the Last-Modified date using a String.
* @param instant the last modified instant
* @return
*/
public io.vertx.reactivex.ext.web.RoutingContext lastModified(String instant) {
delegate.lastModified(instant);
return this;
}
See end
Params: - chunk –
- handler –
Returns:
/**
* See {@link io.vertx.reactivex.ext.web.RoutingContext#end}
* @param chunk
* @param handler
* @return
*/
public io.vertx.reactivex.ext.web.RoutingContext end(String chunk, Handler<AsyncResult<Void>> handler) {
delegate.end(chunk, handler);
return this;
}
See end
Params: - chunk –
Returns:
/**
* See {@link io.vertx.reactivex.ext.web.RoutingContext#end}
* @param chunk
* @return
*/
public io.vertx.reactivex.ext.web.RoutingContext end(String chunk) {
return
end(chunk, ar -> { });
}
See end
Params: - chunk –
Returns:
/**
* See {@link io.vertx.reactivex.ext.web.RoutingContext#end}
* @param chunk
* @return
*/
public io.reactivex.Completable rxEnd(String chunk) {
return AsyncResultCompletable.toCompletable($handler -> {
end(chunk, $handler);
});
}
See end
Params: - buffer –
- handler –
Returns:
/**
* See {@link io.vertx.reactivex.ext.web.RoutingContext#end}
* @param buffer
* @param handler
* @return
*/
public io.vertx.reactivex.ext.web.RoutingContext end(io.vertx.reactivex.core.buffer.Buffer buffer, Handler<AsyncResult<Void>> handler) {
delegate.end(buffer.getDelegate(), handler);
return this;
}
See end
Params: - buffer –
Returns:
/**
* See {@link io.vertx.reactivex.ext.web.RoutingContext#end}
* @param buffer
* @return
*/
public io.vertx.reactivex.ext.web.RoutingContext end(io.vertx.reactivex.core.buffer.Buffer buffer) {
return
end(buffer, ar -> { });
}
See end
Params: - buffer –
Returns:
/**
* See {@link io.vertx.reactivex.ext.web.RoutingContext#end}
* @param buffer
* @return
*/
public io.reactivex.Completable rxEnd(io.vertx.reactivex.core.buffer.Buffer buffer) {
return AsyncResultCompletable.toCompletable($handler -> {
end(buffer, $handler);
});
}
See end
Params: - handler –
Returns:
/**
* See {@link io.vertx.reactivex.ext.web.RoutingContext#end}
* @param handler
* @return
*/
public io.vertx.reactivex.ext.web.RoutingContext end(Handler<AsyncResult<Void>> handler) {
delegate.end(handler);
return this;
}
See end
Returns:
/**
* See {@link io.vertx.reactivex.ext.web.RoutingContext#end}
* @return
*/
public io.vertx.reactivex.ext.web.RoutingContext end() {
return
end(ar -> { });
}
See end
Returns:
/**
* See {@link io.vertx.reactivex.ext.web.RoutingContext#end}
* @return
*/
public io.reactivex.Completable rxEnd() {
return AsyncResultCompletable.toCompletable($handler -> {
end($handler);
});
}
Returns: all the context data as a map
/**
* @return all the context data as a map
*/
public java.util.Map<String, java.lang.Object> data() {
java.util.Map<String, java.lang.Object> ret = delegate.data();
return ret;
}
Always decode the current query string with the given encoding
. The decode result is never cached. Callers to this method are expected to cache the result if needed. Usually users should use queryParams
. This method is only useful when the requests without content type (GET
requests as an example) expect that
query params are in the ASCII format ISO-5559-1
.
Params: - encoding – a non null character set.
Returns: the multimap of query parameters
/**
* Always decode the current query string with the given <code>encoding</code>. The decode result is never cached. Callers
* to this method are expected to cache the result if needed. Usually users should use {@link io.vertx.reactivex.ext.web.RoutingContext#queryParams}.
*
* This method is only useful when the requests without content type (<code>GET</code> requests as an example) expect that
* query params are in the ASCII format <code>ISO-5559-1</code>.
* @param encoding a non null character set.
* @return the multimap of query parameters
*/
public io.vertx.reactivex.core.MultiMap queryParams(java.nio.charset.Charset encoding) {
io.vertx.reactivex.core.MultiMap ret = io.vertx.reactivex.core.MultiMap.newInstance((io.vertx.core.MultiMap)delegate.queryParams(encoding));
return ret;
}
Set the Last-Modified date using a Instant.
Params: - instant – the last modified instant
Returns:
/**
* Set the Last-Modified date using a Instant.
* @param instant the last modified instant
* @return
*/
public io.vertx.reactivex.ext.web.RoutingContext lastModified(java.time.Instant instant) {
delegate.lastModified(instant);
return this;
}
private io.vertx.reactivex.core.http.HttpServerRequest cached_0;
private io.vertx.reactivex.core.http.HttpServerResponse cached_1;
private io.vertx.reactivex.core.Vertx cached_2;
private java.lang.Throwable cached_3;
private java.lang.Integer cached_4;
private io.vertx.reactivex.ext.web.ParsedHeaderValues cached_5;
private List<io.vertx.reactivex.ext.web.LanguageHeader> cached_6;
private io.vertx.reactivex.ext.web.LanguageHeader cached_7;
private java.lang.Boolean cached_8;
public static RoutingContext newInstance(io.vertx.ext.web.RoutingContext arg) {
return arg != null ? new RoutingContext(arg) : null;
}
}