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