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 Fluxzero’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
DeserializingMessagerepresenting aWEBREQUEST - Implements Jooby’s
DefaultContextto 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 WebPatterns 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 Fluxzero only uses a subset of Jooby's APIs for request introspection (not response handling).
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classprotected static classprotected static classNested 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.Contextio.jooby.Contextstatic DefaultWebRequestContextReturns the currentDefaultWebRequestContextfrom the activeDeserializingMessage, ornullif 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.booleanio.jooby.StatusCodegetResponseHeader(String name) longio.jooby.MediaTypeio.jooby.Routerstatic DefaultWebRequestContextgetWebRequestContext(DeserializingMessage message) Creates or retrieves aDefaultWebRequestContextfrom the givenDeserializingMessage.booleanbooleanbooleanmatchesAny(Collection<String> urlPatterns) io.jooby.ContextonComplete(io.jooby.Route.Complete task) pathMap()io.jooby.ContextremoveResponseHeader(String name) io.jooby.Contextio.jooby.SenderresponseWriter(io.jooby.MediaType contentType) io.jooby.Contextsend(byte[] data) io.jooby.Contextsend(io.jooby.output.Output output) io.jooby.Contextsend(io.jooby.StatusCode statusCode) io.jooby.Contextsend(InputStream input) io.jooby.Contextio.jooby.Contextsend(ByteBuffer data) io.jooby.Contextsend(ByteBuffer[] data) io.jooby.Contextsend(FileChannel file) io.jooby.Contextsend(ReadableByteChannel channel) io.jooby.ContextsetDefaultResponseType(io.jooby.MediaType contentType) io.jooby.Contextio.jooby.Contextio.jooby.ContextsetPort(int port) io.jooby.ContextsetRemoteAddress(String remoteAddress) io.jooby.ContextsetRequestPath(String path) io.jooby.ContextsetResetHeadersOnError(boolean value) io.jooby.ContextsetResponseCode(int statusCode) io.jooby.ContextsetResponseCookie(io.jooby.Cookie cookie) io.jooby.ContextsetResponseHeader(String name, String value) io.jooby.ContextsetResponseLength(long length) io.jooby.ContextsetResponseType(io.jooby.MediaType contentType) io.jooby.ContextsetResponseType(String contentType) io.jooby.Contextio.jooby.Contextupgrade(io.jooby.ServerSentEmitter.Handler handler) io.jooby.Contextupgrade(io.jooby.WebSocket.Initializer handler) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.jooby.Context
body, cookieMap, form, getAttributes, getContextPath, getMethod, getRemoteAddress, getRequestPath, getRoute, header, isPreflight, locale, locale, locales, locales, lookup, query, setPathMap, setRouteMethods inherited from interface io.jooby.DefaultContext
accept, accept, body, body, cookie, cookie, decode, decoder, file, files, files, flash, flash, flash, flashOrNull, form, form, formMap, forward, getAttribute, getHost, getHostAndPort, getOutputFactory, getPort, getRequestLength, getRequestType, getRequestType, getRequestURL, getRequestURL, getServerHost, getServerPort, getUser, getValueFactory, header, header, headerMap, isSecure, lookup, lookup, matches, path, path, path, query, query, query, queryMap, queryString, render, require, require, require, require, require, responseStream, responseStream, responseStream, responseWriter, responseWriter, responseWriter, send, send, send, send, sendError, sendError, sendRedirect, sendRedirect, session, session, session, sessionOrNull, setAttribute, setResponseCode, setResponseHeader, setResponseHeader, setResponseHeader, setUserMethods inherited from interface WebRequestContext
getCookieParameter, getFormParameter, getHeaderParameter, getParameter, getPathParameter, getQueryParameter
-
Method Details
-
getCurrentWebRequestContext
Returns the currentDefaultWebRequestContextfrom the activeDeserializingMessage, ornullif 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, ornullif unavailable - See Also:
-
getWebRequestContext
Creates or retrieves aDefaultWebRequestContextfrom 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, anIllegalArgumentExceptionis thrown.- Parameters:
message- a deserializedWEBREQUESTmessage- Returns:
- a
DefaultWebRequestContextwrapping the request metadata and body - Throws:
IllegalArgumentException- if the message type is notWEBREQUEST- See Also:
-
pathMap
-
getParameter
Description copied from interface:WebRequestContextRetrieves the value of a specified parameter from the given sources in a web request.- Specified by:
getParameterin 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
ParameterValueassociated with the specified parameter name and sources, or an emptyParameterValueif the parameter is not found.
-
getProtocol
- Specified by:
getProtocolin interfaceio.jooby.Context
-
getClientCertificates
- Specified by:
getClientCertificatesin interfaceio.jooby.Context
-
getScheme
- Specified by:
getSchemein interfaceio.jooby.Context
-
setRemoteAddress
- Specified by:
setRemoteAddressin interfaceio.jooby.Context
-
setHost
- Specified by:
setHostin interfaceio.jooby.Context
-
setPort
@NotNull public io.jooby.Context setPort(int port) - Specified by:
setPortin interfaceio.jooby.Context
-
setScheme
- Specified by:
setSchemein interfaceio.jooby.Context
-
isInIoThread
public boolean isInIoThread()- Specified by:
isInIoThreadin interfaceio.jooby.Context
-
dispatch
- Specified by:
dispatchin interfaceio.jooby.Context
-
dispatch
-
upgrade
@NotNull public io.jooby.Context upgrade(@NotNull io.jooby.WebSocket.Initializer handler) - Specified by:
upgradein interfaceio.jooby.Context
-
upgrade
@NotNull public io.jooby.Context upgrade(@NotNull io.jooby.ServerSentEmitter.Handler handler) - Specified by:
upgradein interfaceio.jooby.Context
-
setResponseHeader
-
removeResponseHeader
- Specified by:
removeResponseHeaderin interfaceio.jooby.Context
-
removeResponseHeaders
@NotNull public io.jooby.Context removeResponseHeaders()- Specified by:
removeResponseHeadersin interfaceio.jooby.Context
-
setResponseLength
@NotNull public io.jooby.Context setResponseLength(long length) - Specified by:
setResponseLengthin interfaceio.jooby.Context
-
getResponseHeader
-
getResponseLength
public long getResponseLength()- Specified by:
getResponseLengthin interfaceio.jooby.Context
-
isResponseStarted
public boolean isResponseStarted()- Specified by:
isResponseStartedin interfaceio.jooby.Context
-
getResetHeadersOnError
public boolean getResetHeadersOnError()- Specified by:
getResetHeadersOnErrorin interfaceio.jooby.Context
-
getResponseType
@NotNull public io.jooby.MediaType getResponseType()- Specified by:
getResponseTypein interfaceio.jooby.Context
-
setResponseCode
@NotNull public io.jooby.Context setResponseCode(int statusCode) - Specified by:
setResponseCodein interfaceio.jooby.Context
-
getResponseCode
@NotNull public io.jooby.StatusCode getResponseCode()- Specified by:
getResponseCodein interfaceio.jooby.Context
-
responseStream
- Specified by:
responseStreamin interfaceio.jooby.Context
-
responseSender
@NotNull public io.jooby.Sender responseSender()- Specified by:
responseSenderin interfaceio.jooby.Context
-
responseWriter
- Specified by:
responseWriterin interfaceio.jooby.Context
-
getRouter
@NotNull public io.jooby.Router getRouter()- Specified by:
getRouterin interfaceio.jooby.Context
-
setMethod
- Specified by:
setMethodin interfaceio.jooby.Context
-
setRequestPath
- Specified by:
setRequestPathin interfaceio.jooby.Context
-
send
-
send
@NotNull public io.jooby.Context send(@NotNull byte[] data) - Specified by:
sendin interfaceio.jooby.Context
-
send
- Specified by:
sendin interfaceio.jooby.Context
-
send
@NotNull public io.jooby.Context send(@NotNull io.jooby.output.Output output) - Specified by:
sendin interfaceio.jooby.Context
-
send
- Specified by:
sendin interfaceio.jooby.Context
-
send
- Specified by:
sendin interfaceio.jooby.Context
-
send
- Specified by:
sendin interfaceio.jooby.Context
-
send
- Specified by:
sendin interfaceio.jooby.Context
-
send
@NotNull public io.jooby.Context send(@NotNull io.jooby.StatusCode statusCode) - Specified by:
sendin interfaceio.jooby.Context
-
setResetHeadersOnError
@NotNull public io.jooby.Context setResetHeadersOnError(boolean value) - Specified by:
setResetHeadersOnErrorin interfaceio.jooby.Context
-
setResponseCookie
@NotNull public io.jooby.Context setResponseCookie(@NotNull io.jooby.Cookie cookie) - Specified by:
setResponseCookiein interfaceio.jooby.Context
-
setResponseType
- Specified by:
setResponseTypein interfaceio.jooby.Context
-
setResponseType
@NotNull public io.jooby.Context setResponseType(@NotNull io.jooby.MediaType contentType) - Specified by:
setResponseTypein interfaceio.jooby.Context
-
setDefaultResponseType
@NotNull public io.jooby.Context setDefaultResponseType(@NotNull io.jooby.MediaType contentType) - Specified by:
setDefaultResponseTypein interfaceio.jooby.Context
-
onComplete
@NotNull public io.jooby.Context onComplete(@NotNull io.jooby.Route.Complete task) - Specified by:
onCompletein interfaceio.jooby.Context
-
matchesAny
-