Class DefaultWebRequestContext
- All Implemented Interfaces:
WebRequestContext
,io.jooby.Context
,io.jooby.DefaultContext
,io.jooby.Registry
WebRequestContext
that adapts a DeserializingMessage
of type
MessageType.WEBREQUEST
to a Jooby-compatible Context
.
This context serves as the main bridge between Flux Capacitor’s web messaging infrastructure and the Jooby framework’s routing, parameter resolution, and content access APIs. It enables handler matching and invocation based on path, query, form, header, and cookie parameters.
Purpose
DefaultWebRequestContext
wraps incoming web request metadata into an object that behaves
like a live HTTP request. It can be used during handler method resolution to extract parameter values,
match URI paths, handle routing with method + origin specificity, and access request body, headers, etc.
Internals
- Backed by a
DeserializingMessage
representing aWEBREQUEST
- Implements Jooby’s
DefaultContext
to take advantage of its form/query/header abstractions - Supports delayed body deserialization using a
Supplier<byte[]>
- Provides metadata-based implementations of headers, cookies, and remote address resolution
- Can be accessed statically from
getCurrentWebRequestContext()
Usage in Routing
Used primarily byWebHandlerMatcher
, this context provides the
foundation for matching WebPattern
s and routing to appropriate
handler methods.
Extensibility
While this implementation currently delegates most parsing and matching to Jooby, the abstraction is intentionally based on theWebRequestContext
interface to allow future replacement of Jooby with another HTTP framework
without affecting the rest of the dispatching system.
Many Jooby methods are stubbed or unsupported, as Flux only uses a subset of Jooby's APIs for request introspection (not response handling).
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class
protected static class
protected static class
Nested classes/interfaces inherited from interface io.jooby.Context
io.jooby.Context.Selector
-
Field Summary
Fields inherited from interface io.jooby.Context
ACCEPT, GMT, PORT, RFC1123, RFC1123_PATTERN, SECURE_PORT
-
Method Summary
Modifier and TypeMethodDescriptionio.jooby.Context
detach
(io.jooby.Route.Handler next) io.jooby.Context
io.jooby.Context
static DefaultWebRequestContext
Returns the currentDefaultWebRequestContext
from the activeDeserializingMessage
, ornull
if no such message is available or it is not aMessageType.WEBREQUEST
.getParameter
(String name, WebParameterSource... sources) Retrieves the value of a specified parameter from the given sources in a web request.boolean
io.jooby.StatusCode
getResponseHeader
(String name) long
io.jooby.MediaType
io.jooby.Router
static DefaultWebRequestContext
getWebRequestContext
(DeserializingMessage message) Creates or retrieves aDefaultWebRequestContext
from the givenDeserializingMessage
.boolean
boolean
boolean
matchesAny
(Collection<String> urlPatterns) io.jooby.Context
onComplete
(io.jooby.Route.Complete task) pathMap()
io.jooby.Context
removeResponseHeader
(String name) io.jooby.Context
io.jooby.Sender
responseWriter
(io.jooby.MediaType contentType, Charset charset) io.jooby.Context
send
(byte[] data) io.jooby.Context
send
(io.jooby.buffer.DataBuffer data) io.jooby.Context
send
(io.jooby.StatusCode statusCode) io.jooby.Context
send
(InputStream input) io.jooby.Context
io.jooby.Context
send
(ByteBuffer data) io.jooby.Context
send
(ByteBuffer[] data) io.jooby.Context
send
(FileChannel file) io.jooby.Context
send
(ReadableByteChannel channel) io.jooby.Context
setDefaultResponseType
(io.jooby.MediaType contentType) io.jooby.Context
io.jooby.Context
io.jooby.Context
setPort
(int port) io.jooby.Context
setRemoteAddress
(String remoteAddress) io.jooby.Context
setRequestPath
(String path) io.jooby.Context
setResetHeadersOnError
(boolean value) io.jooby.Context
setResponseCode
(int statusCode) io.jooby.Context
setResponseCookie
(io.jooby.Cookie cookie) io.jooby.Context
setResponseHeader
(String name, String value) io.jooby.Context
setResponseLength
(long length) io.jooby.Context
setResponseType
(io.jooby.MediaType contentType, Charset charset) io.jooby.Context
setResponseType
(String contentType) io.jooby.Context
io.jooby.Context
upgrade
(io.jooby.ServerSentEmitter.Handler handler) io.jooby.Context
upgrade
(io.jooby.WebSocket.Initializer handler) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.jooby.Context
body, convert, cookieMap, form, getAttributes, getContextPath, getMethod, getRemoteAddress, getRequestPath, getRoute, header, isPreflight, locale, locale, locales, locales, lookup, lookup, lookup, query, setPathMap, setRoute
Methods inherited from interface io.jooby.DefaultContext
accept, accept, body, body, convertOrNull, cookie, decode, decoder, file, files, files, flash, flash, flashOrNull, form, form, formMap, forward, getAttribute, getBufferFactory, getHost, getHostAndPort, getPort, getRequestLength, getRequestType, getRequestType, getRequestURL, getRequestURL, getServerHost, getServerPort, getUser, header, headerMap, isSecure, matches, path, path, path, query, query, queryMap, queryString, render, require, require, require, require, require, responseStream, responseStream, responseStream, responseWriter, responseWriter, responseWriter, responseWriter, responseWriter, send, send, send, send, sendError, sendError, sendRedirect, sendRedirect, session, session, sessionOrNull, setAttribute, setResponseCode, setResponseHeader, setResponseHeader, setResponseHeader, setResponseType, setUser
Methods inherited from interface io.fluxcapacitor.javaclient.web.WebRequestContext
getCookieParameter, getFormParameter, getHeaderParameter, getParameter, getPathParameter, getQueryParameter
-
Method Details
-
getCurrentWebRequestContext
Returns the currentDefaultWebRequestContext
from the activeDeserializingMessage
, ornull
if no such message is available or it is not aMessageType.WEBREQUEST
.This method provides a convenient way to access the web request context during handler invocation, filtering, or logging without needing to explicitly pass it around.
- Returns:
- the current
DefaultWebRequestContext
, ornull
if unavailable - See Also:
-
getWebRequestContext
Creates or retrieves aDefaultWebRequestContext
from the givenDeserializingMessage
.Internally caches the context in the message so that repeated lookups are efficient. This method should only be used with messages of type
MessageType.WEBREQUEST
; otherwise, anIllegalArgumentException
is thrown.- Parameters:
message
- a deserializedWEBREQUEST
message- Returns:
- a
DefaultWebRequestContext
wrapping the request metadata and body - Throws:
IllegalArgumentException
- if the message type is notWEBREQUEST
- See Also:
-
pathMap
- Specified by:
pathMap
in interfaceio.jooby.Context
-
getParameter
Description copied from interface:WebRequestContext
Retrieves the value of a specified parameter from the given sources in a web request.- Specified by:
getParameter
in interfaceWebRequestContext
- Parameters:
name
- the name of the parameter to retrieve. Must not be null.sources
- the sources to look for the parameter, such as PATH, QUERY, HEADER, COOKIE, or FORM. If no sources are provided, the method may default to a predefined set of sources.- Returns:
- the
ParameterValue
associated with the specified parameter name and sources, or an emptyParameterValue
if the parameter is not found.
-
getProtocol
- Specified by:
getProtocol
in interfaceio.jooby.Context
-
getClientCertificates
- Specified by:
getClientCertificates
in interfaceio.jooby.Context
-
getScheme
- Specified by:
getScheme
in interfaceio.jooby.Context
-
setRemoteAddress
- Specified by:
setRemoteAddress
in interfaceio.jooby.Context
-
setHost
- Specified by:
setHost
in interfaceio.jooby.Context
-
setPort
@NotNull public io.jooby.Context setPort(int port) - Specified by:
setPort
in interfaceio.jooby.Context
-
setScheme
- Specified by:
setScheme
in interfaceio.jooby.Context
-
isInIoThread
public boolean isInIoThread()- Specified by:
isInIoThread
in interfaceio.jooby.Context
-
dispatch
- Specified by:
dispatch
in interfaceio.jooby.Context
-
dispatch
- Specified by:
dispatch
in interfaceio.jooby.Context
-
detach
- Specified by:
detach
in interfaceio.jooby.Context
- Throws:
Exception
-
upgrade
@NotNull public io.jooby.Context upgrade(@NotNull io.jooby.WebSocket.Initializer handler) - Specified by:
upgrade
in interfaceio.jooby.Context
-
upgrade
@NotNull public io.jooby.Context upgrade(@NotNull io.jooby.ServerSentEmitter.Handler handler) - Specified by:
upgrade
in interfaceio.jooby.Context
-
setResponseHeader
- Specified by:
setResponseHeader
in interfaceio.jooby.Context
-
removeResponseHeader
- Specified by:
removeResponseHeader
in interfaceio.jooby.Context
-
removeResponseHeaders
@NotNull public io.jooby.Context removeResponseHeaders()- Specified by:
removeResponseHeaders
in interfaceio.jooby.Context
-
setResponseLength
@NotNull public io.jooby.Context setResponseLength(long length) - Specified by:
setResponseLength
in interfaceio.jooby.Context
-
getResponseHeader
- Specified by:
getResponseHeader
in interfaceio.jooby.Context
-
getResponseLength
public long getResponseLength()- Specified by:
getResponseLength
in interfaceio.jooby.Context
-
isResponseStarted
public boolean isResponseStarted()- Specified by:
isResponseStarted
in interfaceio.jooby.Context
-
getResetHeadersOnError
public boolean getResetHeadersOnError()- Specified by:
getResetHeadersOnError
in interfaceio.jooby.Context
-
getResponseType
@NotNull public io.jooby.MediaType getResponseType()- Specified by:
getResponseType
in interfaceio.jooby.Context
-
setResponseCode
@NotNull public io.jooby.Context setResponseCode(int statusCode) - Specified by:
setResponseCode
in interfaceio.jooby.Context
-
getResponseCode
@NotNull public io.jooby.StatusCode getResponseCode()- Specified by:
getResponseCode
in interfaceio.jooby.Context
-
responseStream
- Specified by:
responseStream
in interfaceio.jooby.Context
-
responseSender
@NotNull public io.jooby.Sender responseSender()- Specified by:
responseSender
in interfaceio.jooby.Context
-
responseWriter
@NotNull public PrintWriter responseWriter(@NotNull io.jooby.MediaType contentType, @Nullable Charset charset) - Specified by:
responseWriter
in interfaceio.jooby.Context
-
getRouter
@NotNull public io.jooby.Router getRouter()- Specified by:
getRouter
in interfaceio.jooby.Context
-
setMethod
- Specified by:
setMethod
in interfaceio.jooby.Context
-
setRequestPath
- Specified by:
setRequestPath
in interfaceio.jooby.Context
-
send
- Specified by:
send
in interfaceio.jooby.Context
-
send
@NotNull public io.jooby.Context send(@NotNull byte[] data) - Specified by:
send
in interfaceio.jooby.Context
-
send
- Specified by:
send
in interfaceio.jooby.Context
-
send
@NotNull public io.jooby.Context send(@NotNull io.jooby.buffer.DataBuffer data) - Specified by:
send
in interfaceio.jooby.Context
-
send
- Specified by:
send
in interfaceio.jooby.Context
-
send
- Specified by:
send
in interfaceio.jooby.Context
-
send
- Specified by:
send
in interfaceio.jooby.Context
-
send
- Specified by:
send
in interfaceio.jooby.Context
-
send
@NotNull public io.jooby.Context send(@NotNull io.jooby.StatusCode statusCode) - Specified by:
send
in interfaceio.jooby.Context
-
setResetHeadersOnError
@NotNull public io.jooby.Context setResetHeadersOnError(boolean value) - Specified by:
setResetHeadersOnError
in interfaceio.jooby.Context
-
setResponseCookie
@NotNull public io.jooby.Context setResponseCookie(@NotNull io.jooby.Cookie cookie) - Specified by:
setResponseCookie
in interfaceio.jooby.Context
-
setResponseType
- Specified by:
setResponseType
in interfaceio.jooby.Context
-
setResponseType
@NotNull public io.jooby.Context setResponseType(@NotNull io.jooby.MediaType contentType, @Nullable Charset charset) - Specified by:
setResponseType
in interfaceio.jooby.Context
-
setDefaultResponseType
@NotNull public io.jooby.Context setDefaultResponseType(@NotNull io.jooby.MediaType contentType) - Specified by:
setDefaultResponseType
in interfaceio.jooby.Context
-
onComplete
@NotNull public io.jooby.Context onComplete(@NotNull io.jooby.Route.Complete task) - Specified by:
onComplete
in interfaceio.jooby.Context
-
matchesAny
-