validateContentType
public static <A> Accumulator<akka.util.ByteString,F.Either<Result,A>> validateContentType(HttpErrorHandler errorHandler,
Http.RequestHeader request,
java.lang.String errorMessage,
java.util.function.Function<java.lang.String,java.lang.Boolean> validate,
java.util.function.Function<Http.RequestHeader,Accumulator<akka.util.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.