@@ -5,12 +5,27 @@ enum BlobEventType { write, delete }
5
5
/// The context of a Blob event request/response.
6
6
class BlobEventContext
7
7
extends TriggerContext <BlobEventRequest , BlobEventResponse > {
8
- BlobEventContext (super .id, super .req, super .resp);
8
+ late BlobEventHandler _nextHandler;
9
+
10
+ BlobEventContext (super .id, super .req, super .resp,
11
+ {next = _defaultHandler< BlobEventContext > }) {
12
+ _nextHandler = next;
13
+ }
9
14
10
15
/// Create a Blob Event context from a server message.
11
16
BlobEventContext .fromRequest ($bp.ServerMessage msg)
12
- : this (msg.id, BlobEventRequest (msg.blobEventRequest.blobEvent.key),
13
- BlobEventResponse ());
17
+ : this (
18
+ msg.id,
19
+ BlobEventRequest (msg.blobEventRequest.blobEvent.key),
20
+ BlobEventResponse (),
21
+ );
22
+
23
+ BlobEventContext .fromCtx (BlobEventContext ctx, BlobEventHandler next)
24
+ : this (ctx.id, ctx.req, ctx.res, next: next);
25
+
26
+ Future <BlobEventContext > next () async {
27
+ return await _nextHandler (this );
28
+ }
14
29
15
30
/// Converts the context to a gRPC client response.
16
31
$bp.ClientMessage toResponse () {
@@ -21,14 +36,28 @@ class BlobEventContext
21
36
/// The context of a Blob event request/response.
22
37
class FileEventContext
23
38
extends TriggerContext <FileEventRequest , BlobEventResponse > {
24
- FileEventContext (super .id, super .req, super .resp);
39
+ late FileEventHandler _nextHandler;
40
+
41
+ FileEventContext (super .id, super .req, super .resp,
42
+ {next = _defaultHandler< FileEventContext > }) {
43
+ _nextHandler = next;
44
+ }
25
45
26
46
/// Create a Blob Event context from a server message.
27
47
FileEventContext .fromRequest ($bp.ServerMessage msg, Bucket bucket)
28
48
: this (
29
- msg.id,
30
- FileEventRequest (bucket.file (msg.blobEventRequest.blobEvent.key)),
31
- BlobEventResponse ());
49
+ msg.id,
50
+ FileEventRequest (bucket.file (msg.blobEventRequest.blobEvent.key)),
51
+ BlobEventResponse (),
52
+ );
53
+
54
+ /// Call the next middleware in the middleware chain
55
+ FileEventContext .fromCtx (FileEventContext ctx, FileEventHandler next)
56
+ : this (ctx.id, ctx.req, ctx.res, next: next);
57
+
58
+ Future <FileEventContext > next () async {
59
+ return await _nextHandler (this );
60
+ }
32
61
33
62
/// Converts the context to a gRPC client response.
34
63
$bp.ClientMessage toResponse () {
0 commit comments