public class BodyParsers extends Object
Constructor and Description |
---|
BodyParsers() |
Modifier and Type | Method and Description |
---|---|
static <A> Accumulator<akka.util.ByteString,F.Either<Result,A>> |
validateContentType(HttpErrorHandler errorHandler,
Http.RequestHeader request,
String errorMessage,
Function<String,Boolean> validate,
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.
|
public static <A> Accumulator<akka.util.ByteString,F.Either<Result,A>> validateContentType(HttpErrorHandler errorHandler, Http.RequestHeader request, String errorMessage, Function<String,Boolean> validate, Function<Http.RequestHeader,Accumulator<akka.util.ByteString,F.Either<Result,A>>> parser)
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.
A
- The type to be parsed by the parsererrorHandler
- 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.