Package io.fluxcapacitor.javaclient.web
Class DefaultWebResponseMapper
java.lang.Object
io.fluxcapacitor.javaclient.web.DefaultWebResponseMapper
- All Implemented Interfaces:
ResponseMapper
,WebResponseMapper
Default implementation of
WebResponseMapper
that converts handler return values into WebResponse
objects.
This mapper is used internally to standardize responses from @HandleWeb
methods or forwarded HTTP requests.
It maps return values based on their type, applying common HTTP status codes and payload formatting conventions.
Mapping Rules
The logic follows these conventions:- If the response is already a
WebResponse
, it is returned unchanged - If the response is a known
Throwable
, a corresponding HTTP error code and message are assigned:ValidationException
orDeserializationException
→ 400 Bad RequestUnauthorizedException
orUnauthenticatedException
→ 401 Unauthorized- other
FunctionalException
s → 403 Forbidden TimeoutException
or Flux’s ownTimeoutException
→ 503 Service Unavailable- Any other
Throwable
→ 500 Internal Server Error
- If the response is
null
, the status is set to 204 No Content - Otherwise, the response is treated as a normal payload with status 200 OK
In all cases, the provided Metadata
is added to the resulting response.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionMaps a raw handler return value and associated metadata into aWebResponse
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.fluxcapacitor.javaclient.web.WebResponseMapper
map
-
Constructor Details
-
DefaultWebResponseMapper
public DefaultWebResponseMapper()
-
-
Method Details
-
map
Maps a raw handler return value and associated metadata into aWebResponse
.- Specified by:
map
in interfaceResponseMapper
- Specified by:
map
in interfaceWebResponseMapper
- Parameters:
response
- the return value (may be aWebResponse
, a regular object, or aThrowable
)metadata
- metadata to attach to the response- Returns:
- a mapped
WebResponse
object
-