Package play.mvc
Class BodyParsers
- Object
-
- play.mvc.BodyParsers
-
public class BodyParsers extends Object
Utilities for creating body parsers.
-
-
Constructor Summary
Constructors Constructor Description BodyParsers()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description 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.
-
-
-
Method Detail
-
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.
-
-