Interceptor class

Interceptor middleware for Spry.

Interceptor middleware is used to intercept program exceptions and errors to prevent the program from crashing.

Example:

final Spry spry = Spry();

spry.use(Interceptor());

handler(Context context) {
  throw Exception('This is an exception');
}

await spry.listen(handler, port: 3000);

Constructors

Interceptor.new({ExceptionHandler handler = const ExceptionHandler.plainText()})
Create a Interceptor middleware.
const
Interceptor.json({Object? builder(SpryHttpException exception)?})
Create a json exception handler interceptor.
Interceptor.onlyStatusCode()
Create a only status code no body exception handler interceptor.
const
Interceptor.plainText()
Create a plain text exception handler interceptor.
const

Properties

handler ExceptionHandler
The exception handler.
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

call(Context context, Next next) FutureOr<void>
The interceptor middleware-style function.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
resolve(Context context) ExceptionHandler
Resolve the exception handler from Context.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited