-
- All Known Implementing Classes:
DefaultMediaSupport
,JacksonSupport
,JsonbSupport
,JsonpSupport
,MultiPartSupport
public interface MediaSupport
Service used to register readers and writers to the respective context.MediaSupport instances can be used with WebServer and WebClient to register readers and writer. Each of these have method addMediaSupport(), which will add corresponding support.
WebServer example usage:
WebClient example usage:WebServer.builder() .addMediaSupport(JsonbSupport.create()) .build();
If you need to register MediaSupport on the request or response, you will need to register them to the corresponding context.WebClient.builder() .addMediaSupport(JacksonSupport.create()) .build();
Example request reader registration:
Example response writer registration:Routing.builder() .get("/foo", (res, req) -> { MessageBodyReadableContent content = req.content(); content.registerReader(JsonbSupport.create()) content.as(String.class) .thenAccept(System.out::print); })
Routing.builder() .get("/foo", (res, req) -> { MessageBodyWriterContext writerContext = res.writerContext(); writerContext.registerWriter(JsonbSupport.create()) res.send("Example entity"); })
-
-
Method Summary
All Methods Instance Methods Default Methods Modifier and Type Method Description default Collection<MessageBodyReader<?>>
readers()
Returns the collection of the readers which should be registered.default void
register(MessageBodyReaderContext readerContext, MessageBodyWriterContext writerContext)
Method used to register readers and writers.default Collection<MessageBodyStreamReader<?>>
streamReaders()
Returns the collection of the stream readers which should be registered.default Collection<MessageBodyStreamWriter<?>>
streamWriters()
Returns the collection of the stream writers which should be registered.default Collection<MessageBodyWriter<?>>
writers()
Returns the collection of the writers which should be registered.
-
-
-
Method Detail
-
register
default void register(MessageBodyReaderContext readerContext, MessageBodyWriterContext writerContext)
Method used to register readers and writers.- Parameters:
readerContext
- reader contextwriterContext
- writer context
-
readers
default Collection<MessageBodyReader<?>> readers()
Returns the collection of the readers which should be registered.- Returns:
- readers
-
writers
default Collection<MessageBodyWriter<?>> writers()
Returns the collection of the writers which should be registered.- Returns:
- writers
-
streamReaders
default Collection<MessageBodyStreamReader<?>> streamReaders()
Returns the collection of the stream readers which should be registered.- Returns:
- stream readers
-
streamWriters
default Collection<MessageBodyStreamWriter<?>> streamWriters()
Returns the collection of the stream writers which should be registered.- Returns:
- stream writers
-
-