Interface FilterBodyParser

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface @DefaultImplementation(io.micronaut.http.server.filter.DefaultFilterBodyParser.class) public interface FilterBodyParser
API to parse a request body within a server filter.
Since:
4.7.1
Author:
Sergio del Amo
See Also:
  • Method Details

    • parseBody

      @NonNull CompletableFuture<Map<String,Object>> parseBody(@NonNull HttpRequest<?> request)
      Attempts to parse the request body into a Map. The default implementation DefaultFilterBodyParser uses FormUrlEncodedDecoder for form-url-encoded payloads and a JsonMapper for JSON payloads. form-url-encoded payloads are first decoded into a Map with key String and value List<String>. Then, the map is flattened to a Map of key String and value Object>. If original's map value is a list of 1 item, the item of that list becomes the value of the resulting map.
      Parameters:
      request - HTTP Request
      Returns:
      a publisher which emits a single item or an empty publisher if the request body cannot be parsed to a Map.