Annotation Interface Body


@Documented @Retention(SOURCE) @Target(PARAMETER) public @interface Body

Binds the payload of a request to a web route method parameter.

The type of the annotated parameter can either be:

  • ByteBuf, Mono<ByteBuf>, Flux<ByteBuf> or Publisher<ByteBuf> to consume raw data
  • Mono<Parameter>, Flux<Parameter> or Publisher<Parameter> to consume URL encoded form data
  • Mono<T>, Flux<T> or Publisher<T> where type T is a super type of WebPart to consume multipart form data
  • T, Mono<T>, Flux<T> or Publisher<T> where type T is neither a ByteBuf, nor a Parameter, nor a super type of WebPart to consume decoded data based on the content type of the request.

An encoded request payload is decoded using one of the MediaTypeConverter injected in the web server module and corresponding to the content type of the request.


 @WebRoute( method = Method.POST, consumes = MediaTypes.APPLICATION_JSON )
 public void create(Book book) {
     ...
 }

 @WebRoute( method = Method.POST, consumes = MediaTypes.APPLICATION_X_NDJSON )
 public void createReactive(Flux<Book> book) {
     ...
 }
 

This annotation can't be used in conjunction with @FormParam.

Since:
1.0
Author:
Jeremy Kuhn
See Also: