Interface MediaSupport

  • 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:
    
     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 Detail

      • 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