@@ -20,22 +20,43 @@ import 'cloud_event.dart';
2020import 'log_severity.dart' ;
2121import 'request_context.dart' ;
2222
23+ /// The shape of a handler for [CloudEvent] types.
2324typedef CloudEventHandler = FutureOr <void > Function (CloudEvent request);
2425
26+ /// The shape of a handler for [CloudEvent] types while also providing a
27+ /// [RequestContext] .
2528typedef CloudEventWithContextHandler = FutureOr <void > Function (
2629 CloudEvent request,
2730 RequestContext context,
2831);
2932
33+ /// The shape of a handler that supports a custom [RequestType] and
34+ /// [ResponseType] .
35+ ///
36+ /// The [RequestType] must be either a type compatible with a JSON literal or
37+ /// have a `fromJson` constructor with a single, positional parameter that is
38+ /// compatible with a JSON literal.
39+ ///
40+ /// The [ResponseType] must be either a type compatible with a JSON literal or
41+ /// have a `toJson()` function with a returns type compatible with a JSON
42+ /// literal.
3043typedef JsonHandler <RequestType , ResponseType > = FutureOr <ResponseType >
3144 Function (RequestType request);
3245
46+ /// The shape of a handler that supports a custom [RequestType] and
47+ /// [ResponseType] and while also providing a [RequestContext] .
48+ ///
49+ /// See [JsonHandler] for the type requirements for [RequestType] and
50+ /// [ResponseType] .
3351typedef JsonWithContextHandler <RequestType , ResponseType >
3452 = FutureOr <ResponseType > Function (
3553 RequestType request,
3654 RequestContext context,
3755);
3856
57+ /// The shape of a basic handler that follows the
58+ /// [package:shelf] (https://pub.dev/packages/shelf) [Handler] pattern while also
59+ /// providing a [RequestLogger] .
3960typedef HandlerWithLogger = FutureOr <Response > Function (
4061 Request request,
4162 RequestLogger logger,
0 commit comments