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.
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).
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.
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.
Set Content-Disposition get to "attachment" with optional filename
mime type.
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.
See {@link RoutingContext#end}
See {@link RoutingContext#end}
See {@link RoutingContext#end}
See {@link RoutingContext#end}
See {@link RoutingContext#end}
See {@link RoutingContext#end}
Set the ETag of a response. This will normalize the quotes if necessary.
etag('md5hashsum'); etag('"md5hashsum"'); ('W/"123456789"');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 {@link Router#errorHandler}. If no error handler is not defined, It will send a default failure response with provided status code.
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 {@link Router#errorHandler}. If no error handler is not defined, It will send a default failure response with 500 status code.
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 {@link Router#errorHandler}. If no error handler is not defined, It will send a default failure response with provided status code.
If the context is being routed to failure handlers after a failure has been triggered by calling {@link 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.
Get some data from the context. The data is available in any handlers that receive the context.
Get some data from the context. The data is available in any handlers that receive the context.
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.
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.
Check if the request is fresh, aka Last-Modified and/or the ETag still match.
Whether the {@link RoutingContext#session} has been already called or not. This is usually used by the SessionHandler.
See {@link RoutingContext#json}.
See {@link RoutingContext#json}.
Set the Last-Modified date using a String.
Set the Last-Modified date using a Instant.
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.
Use {@link RoutingContext#normalizedPath} instead
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.
The headers:
Gets the value of a single path parameter
Returns a map of named parameters as defined in path declaration with their actual values
Helper to return the user preferred language. It is the same action as returning the first element of the acceptable languages.
Put some arbitrary data in the context. This will be available in any handlers that receive the context.
Gets the value of a single query parameter. For more info {@link RoutingContext#queryParams}
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
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 {@link RoutingContext#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
.
See {@link RoutingContext#redirect}.
See {@link RoutingContext#redirect}.
Remove some data from the context. The data is available in any handlers that receive the context.
Remove a body end handler
Remove an end handler
Remove a headers end handler
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.
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.
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.
Set the acceptable content type. Used by
Set the user. Usually used by auth handlers to inject a User. You will not normally call this method.
If the context is being routed to failure handlers after a failure has been triggered by calling {@link 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.
Get the authenticated user (if any). This will usually be injected by an auth handler if authentication if successful.
Generated using TypeDoc
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 {@link Handler#handle} 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