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
If there are under tests case or would like to get a temp port, you should use number `0` as the argument.
183
186
184
-
The parsed http url, see https://nodejs.org/dist/latest-v9.x/docs/api/url.html#url_url_strings_and_url_objects for more info.
187
+
If port is omitted or is 0, the operating system will assign an arbitrary unused port, which can be retrieved by using Router.getListeningAddress().port after the 'listening' event has been emitted.
188
+
189
+
```
190
+
router.listen(7777);
191
+
```
192
+
193
+
## `close()`
194
+
195
+
Close the server.
196
+
197
+
```
198
+
router.close();
199
+
```
200
+
201
+
## `getListeningAddress()`
202
+
203
+
Get the bounding server address info.
204
+
205
+
# Helpers on `Request`
206
+
207
+
## `request.innerRequest`: IncomingMessage
208
+
209
+
The underlying http request.
210
+
211
+
## `request.innerResponse`: ServerResponse
212
+
213
+
The underlying http response.
214
+
215
+
## `request.originalUrl`: string
216
+
217
+
Original, unprocessed request url.
185
218
186
-
###`request. de_queryString`: object
219
+
## `request.parsedUrl`: Url
187
220
188
-
The query string key-value pairs parsed into object format.
221
+
The parsed http url, see https://nodejs.org/dist/latest-v9.x/docs/api/url.html#url_url_strings_and_url_objects for more info.
189
222
190
-
###`request. de_response`: Respond
223
+
## `request.response`: Respond
191
224
192
225
Point to the accompanied Response object.
193
226
194
-
###`request. de_method`: string
227
+
## `request.method`: string
195
228
196
229
The request http method.
197
230
198
-
###`request. de_headers`: object
231
+
## `request.headers`: object
199
232
200
233
The http headers parsed into object format.
201
234
202
-
###`request. de_taskList`: Task[]
235
+
## `request.taskList`: Task[]
203
236
204
237
The tasks waiting for this request.
205
238
206
-
###`request. de_getIp()`: () => string
239
+
## `request.ip`: string
207
240
208
241
Get the client ip and be able to handle behind proxy case.
209
242
210
243
```js
211
-
request.de_getIp();
244
+
request.ip;
212
245
// => "127.0.0.1"
213
246
```
214
247
215
-
###`request.share`: {}
248
+
## `request.share`: {}
216
249
217
-
The app context variable for simply share state between tasks.
250
+
The app context variable for simply share states between tasks.
-`object: Headers` - Object used to set the headers, such as { Accept: "text/plain", "X-API-Key": "dde" }.
228
269
229
270
Set header `key` to its `value`. If the `Content-Type` field is going to be set, this method will automatically turn the value to extensional form, eg."html" to the standard mime forms "text/html", and add the charset if it can be matched in mime-db package.
230
271
231
272
Return the this object, aka. Respond to make chain-able calls available.
- code <number> - Http status code number such as "404"
288
+
-`code: number` - Http status code number such as "404"
248
289
249
290
Set the status `code` of the response.
250
291
@@ -254,9 +295,9 @@ Return this object for chain-able calls.
254
295
response.setStatus(404);
255
296
```
256
297
257
-
###`response. de_send(body)`: (body?) => Response
298
+
## `response.send(body)`: (body?) => Response
258
299
259
-
- body <string | object | buffer> - Can be a string such as `"some string"`, an object such as `{some: "haha"}` and a buffer such as `new Buffer("some buffer")`.
300
+
-`body: string | object | buffer` - Can be a string such as `"some string"`, an object such as `{some: "haha"}` and a buffer such as `new Buffer("some buffer")`.
260
301
261
302
Send response to the remote client, and this method will terminate the underlying socket session.
If there are under tests case or would like to get a temp port, you should use number `0` as the argument.
276
-
277
-
If port is omitted or is 0, the operating system will assign an arbitrary unused port, which can be retrieved by using Router.getListeningAddress().port after the 'listening' event has been emitted.
0 commit comments