call method

Handler call(
  1. Handler innerHandler
)

Implementation

Handler call(Handler innerHandler){

  return (r)async{
    var authData = r.headers[HttpHeaders.authorizationHeader];

    if (authData == null) {
      return Response.unauthorized('Unauthorized');
    }

    try {
      final value = parser.parse(authData);
      var authorization = await validator.validate(parser, value);
      if (authorization == null) {
        return Response.unauthorized('Unauthorized');
      }
      return innerHandler(r);
    } on TokenExpiredException catch(e){
      return Response.unauthorized(e.message);
    } on AuthorizationParserException catch (e) {
      return _responseFromParseException(e);
    }
  };
}