Package play.mvc

Class BodyParsers

java.lang.Object
play.mvc.BodyParsers

public class BodyParsers extends Object
Utilities for creating body parsers.
  • Constructor Details

    • BodyParsers

      public BodyParsers()
  • Method Details

    • validateContentType

      public static <A> Accumulator<ByteString,F.Either<Result,A>> validateContentType(HttpErrorHandler errorHandler, Http.RequestHeader request, String errorMessage, Function<String,Boolean> validate, Function<Http.RequestHeader,Accumulator<ByteString,F.Either<Result,A>>> parser)
      Validate the content type of the passed in request using the given validator.

      If the validator returns true, the passed in accumulator will be returned to parse the body, otherwise an accumulator with a result created by the error handler will be returned.

      Type Parameters:
      A - The type to be parsed by the parser
      Parameters:
      errorHandler - The error handler used to create a bad request result if the content type is not valid.
      request - The request to validate.
      errorMessage - The error message to pass to the error handler if the content type is not valid.
      validate - The validation function.
      parser - The parser to use if the content type is valid.
      Returns:
      An accumulator to parse the body.