spring-framework / org.springframework.web.reactive.function.server / RouterFunctionDsl / accept

accept

fun accept(mediaType: MediaType, f: (ServerRequest) -> Mono<ServerResponse>): Unit

Route to the given handler function if the given accept predicate applies.

See Also

RouterFunctions.route

fun accept(mediaType: MediaType): RequestPredicate

Return a {@code RequestPredicate} that tests if the request's {@linkplain ServerRequest.Headers#accept() accept} header is {@linkplain MediaType#isCompatibleWith(MediaType) compatible} with any of the given media types.

Parameters

mediaTypes - the media types to match the request's accept header against

Return
a predicate that tests the request's accept header against the given media types