YamlReturnValueHandler class final
ReturnValueHandler implementation that handles YAML-serializable controller return values.
This handler activates for controller methods intended to return YAML responses and automatically serializes the return value as YAML using an appropriate HttpMessageConverter.
Overview
When a handler returns an object with YAML media type negotiation, this handler locates an appropriate converter and delegates serialization.
Content-Type header negotiation is applied globally by the DefaultReturnValueHandlerManager before handler invocation, ensuring consistent header management across all handlers.
Responsibilities
- Determine eligibility for YAML serialization
- Select suitable HttpMessageConverter for the object type
- Write response using converter with already-negotiated Content-Type
- Default to
200 OKstatus when applicable
Error Handling
Throws HttpMediaTypeNotSupportedException if no converter can serialize to the requested type.
Related Components
- HttpMessageConverters — registry of available converters
- ResponseBodyReturnValueHandler — handles raw responses
- DefaultReturnValueHandlerManager — applies content negotiation globally
- Implemented types
Constructors
- YamlReturnValueHandler(HttpMessageConverters _converters)
- ReturnValueHandler implementation that handles YAML-serializable controller return values.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
canHandle(
Method? method, Object? returnValue, ServerHttpRequest request) → bool -
Determines whether this handler can handle the given return value.
override
-
equalizedProperties(
) → List< Object?> -
Mixin-style contract for value-based equality,
hashCode, andtoString. -
getSupportedMediaTypes(
) → List< MediaType> -
Returns the list of media types this handler supports by default.
override
-
handleReturnValue(
Object? returnValue, Method? method, ServerHttpRequest request, ServerHttpResponse response, HandlerMethod? hm) → Future< void> -
Processes the return value and writes the appropriate response.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited