annotations library
Used to annotate functions used to configure Server and ServerPipeline.
Overview
The WoomeraAnnotation is the base class for:
- Handles - annotation for request handlers;
- RequestHandlerWrapper - annotation for the wrapper;
- PipelineExceptionHandler - annotation for pipeline exception handlers;
- ServerExceptionHandler - annotation for the server exception handler; and
- ServerExceptionHandlerRaw - annotation for the server raw exception handler.
Examples
Request handlers
@Handles.get('~/form')
Future<Response> myRequestHandler(Request req) async {
...
}
@Handles.post('~/form/submit')
Future<Response> myFormRequestHandler(Request req) async {
...
}
@Handles.put('~/api/foo', pipeline: 'api')
Future<Response> myApiRequestHandler(Request req) async {
...
}
Pipeline exception handlers
A program can have at most one per pipeline.
@PipelineExceptionHandler()
Future<Response> exceptionHandlerForDefaultPipeline(
Request req, Object exception, StackTrace st) async {
...
}
@PipelineExceptionHandler(pipeline: 'api')
Future<Response> exceptionHandlerForApiPipeline(
Request req, Object exception, StackTrace st) async {
...
}
Server exception handler and server raw exception handler.
A program can have at most one of each of these.
@ServerExceptionHandler()
Future<Response> myServerEH(
Request req, Object exception, StackTrace st) async {
...
}
@ServerRawExceptionHandler()
Future<void> myServerRawEH(
HttpRequest r, String requestId, Object exception, StackTrace st) async {
...
}
Note: this library defines classes for creating annotations, but does not use them.
Classes
- Handles
- Annotation for a request handler.
- PipelineExceptionHandler
- Annotation for a pipeline exception handler function.
- RequestHandlerWrapper
- Annotation for a request handler wrapper function.
- ServerExceptionHandler
- Annotation for a server exception handler function.
- ServerExceptionHandlerRaw
- Annotation for a server raw exception handler function.
- WoomeraAnnotation
- Abstract base class for all Woomera annotation classes.
Typedefs
- HandlerWrapper = RequestHandler Function(Handles rego, Object obj)
- Function type for handler wrapper.