You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+108-6Lines changed: 108 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
# Booster rocket webhook Azure
2
2
3
3
## Description
4
-
This Rocket adds a Webhook to your Booster application. When the webhook is called, a function will be executed in your Booster application with request as a parameter.
4
+
This Rocket adds HTTP endpoints to your Booster application. When an endpoint is called, a function will be executed in your Booster application with request as a parameter.
5
5
6
6
## Supported Providers
7
7
@@ -19,11 +19,11 @@ Add your rocket to your application in the configuration file.
19
19
function buildBoosterWebhook(config:BoosterConfig):BoosterWebhook {
20
20
returnnewBoosterWebhook(config, [
21
21
{
22
-
origin: 'test',
22
+
route: 'test',
23
23
handlerClass: TestHandler,
24
24
},
25
25
{
26
-
origin: 'other',
26
+
route: 'clients/other',
27
27
handlerClass: FacebookHandler,
28
28
},
29
29
])
@@ -44,8 +44,15 @@ For Local
44
44
45
45
### Parameters
46
46
47
-
*origin: Identify the webhook. It will be also the name of the endpoint that will be created
47
+
*route: The endpoint that will be created. It is possible to define nested routes.
48
48
* handlerClass: A class with a `handle` method to handle the request
* defParamCharset: the default character set to use for values of part header parameters (e.g. filename)
51
+
* preservePath: If paths in filenames from file parts in a 'multipart/form-data' request shall be preserved.
52
+
* limits:
53
+
* fileSize: the max file size (in bytes)
54
+
* files: the max number of file fields.
55
+
* parts: the max number of parts (fields + files).
49
56
50
57
The `handle` method should be like this one:
51
58
@@ -60,15 +67,16 @@ export class TestHandler {
60
67
thrownewInvalidParameterError("Error message");
61
68
}
62
69
returnPromise.resolve({
63
-
body: { name: "my_name" }
70
+
body: { name: "my_name" },
71
+
responseType: WebhookResponseType.json,
64
72
});
65
73
}
66
74
}
67
75
```
68
76
69
77
## Return type
70
78
71
-
Handle methods return a promise of WebhookHandlerReturnType or void. This object contains the headers and body to be returned as response. Example:
79
+
Handle methods return a promise of WebhookHandlerReturnType or void. This object contains the headers and body to be returned as response. You need to specify the responseType. Example:
72
80
73
81
```typescript
74
82
publicstaticasynchandle(
@@ -80,10 +88,55 @@ Handle methods return a promise of WebhookHandlerReturnType or void. This object
80
88
headers: {
81
89
Test: 'test header',
82
90
},
91
+
responseType: WebhookResponseType.text,
83
92
})
84
93
}
85
94
```
86
95
96
+
To return a file, set the responseType to `WebhookResponseType.file`. Specify the name and mime type in the `file` field.
97
+
98
+
Example:
99
+
100
+
```typescript
101
+
const result:WebhookHandlerReturnType= {
102
+
body: file,
103
+
file: {
104
+
name: '1.txt',
105
+
mimeType: WebhookResponseType.text,
106
+
},
107
+
responseType: WebhookResponseType.file,
108
+
}
109
+
```
110
+
111
+
## Authorization
112
+
113
+
To define with roles can access each point use the `authorize` configuration parameter as the `authorize` parameter in Booster.
@@ -113,6 +166,55 @@ The webhookEventInterface object will be similar to this one:
113
166
}
114
167
```
115
168
169
+
170
+
## Multipart/form-data requests
171
+
172
+
Endpoints accepts multipart/form-data requests. The `WebhookEvent` will contain a new `multiPart` object with the files and fields in the request. Example:
0 commit comments