Skip to content

Commit 96eda87

Browse files
chore: apply automated updates
1 parent 272e1be commit 96eda87

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

Diff for: docs/2.utils/1.request.md

+13
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ icon: material-symbols-light:input
1111
### `assertMethod(event, expected, allowHead?)`
1212

1313
Asserts that the incoming request method is of the expected type using `isMethod`.
14+
1415
If the method is not allowed, it will throw a 405 error with the message "HTTP method is not allowed".
1516

1617
### `getHeader(event, name)`
@@ -20,6 +21,7 @@ Get a request header by name.
2021
### `getHeaders(event)`
2122

2223
Get the request headers object.
24+
2325
Array headers are joined with a comma.
2426

2527
### `getQuery(event)`
@@ -33,29 +35,37 @@ Get a request header by name.
3335
### `getRequestHeaders(event)`
3436

3537
Get the request headers object.
38+
3639
Array headers are joined with a comma.
3740

3841
### `getRequestHost(event, opts: { xForwardedHost? })`
3942

4043
Get the request hostname.
44+
4145
If `xForwardedHost` is `true`, it will use the `x-forwarded-host` header if it exists.
46+
4247
If no host header is found, it will default to "localhost".
4348

4449
### `getRequestIP(event)`
4550

4651
Try to get the client IP address from the incoming request.
52+
4753
If `xForwardedFor` is `true`, it will use the `x-forwarded-for` header if it exists.
4854

4955
### `getRequestProtocol(event, opts: { xForwardedProto? })`
5056

5157
Get the request protocol.
58+
5259
If `x-forwarded-proto` header is set to "https", it will return "https". You can disable this behavior by setting `xForwardedProto` to `false`.
60+
5361
If protocol cannot be determined, it will default to "http".
5462

5563
### `getRequestURL(event, opts: { xForwardedHost?, xForwardedProto? })`
5664

5765
Generated the full incoming request URL using `getRequestProtocol`, `getRequestHost` and `event.path`.
66+
5867
If `xForwardedHost` is `true`, it will use the `x-forwarded-host` header if it exists.
68+
5969
If `xForwardedProto` is `false`, it will not use the `x-forwarded-proto` header.
6070

6171
### `getRouterParam(event, name, opts: { decode? })`
@@ -65,6 +75,7 @@ Get a matched route param by name.
6575
### `getRouterParams(event, opts: { decode? })`
6676

6777
Get matched route params.
78+
6879
If `decode` option is `true`, it will decode the matched route params using `decodeURI`.
6980

7081
### `getValidatedQuery(event, validate)`
@@ -78,11 +89,13 @@ Get matched route params and validate with validate function.
7889
### `isMethod(event, expected, allowHead?)`
7990

8091
Checks if the incoming request method is of the expected type.
92+
8193
If `allowHead` is `true`, it will allow `HEAD` requests to pass if the expected method is `GET`.
8294

8395
### `toWebRequest(event)`
8496

8597
Convert the H3Event to a WebRequest object.
98+
8699
**NOTE:** This function is not stable and might have edge cases that are not handled properly.
87100

88101
<!-- /automd -->

Diff for: docs/2.utils/2.reponse.md

+7
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,15 @@ Remove a response header by name.
6363
### `send(event, data?, type?)`
6464

6565
Directly send a response to the client.
66+
6667
**Note:** This function should be used only when you want to send a response directly without using the `h3` event. Normaly you can directly `return` a value inside event handlers.
6768

6869
### `sendIterable(event, iterable)`
6970

7071
Iterate a source of chunks and send back each chunk in order. Supports mixing async work toghether with emitting chunks.
72+
7173
Each chunk must be a string or a buffer.
74+
7275
For generator (yielding) functions, the returned value is treated the same as yielded values.
7376

7477
**Example:**
@@ -97,17 +100,21 @@ async function delay(ms) {
97100
### `sendNoContent(event, code?)`
98101

99102
Respond with an empty payload.<br>
103+
100104
Note that calling this function will close the connection and no other data can be sent to the client afterwards.
101105

102106
### `sendRedirect(event, location, code)`
103107

104108
Send a redirect response to the client.
109+
105110
It adds the `location` header to the response and sets the status code to 302 by default.
111+
106112
In the body, it sends a simple HTML page with a meta refresh tag to redirect the client in case the headers are ignored.
107113

108114
### `sendStream(event, stream)`
109115

110116
Send a stream response to the client.
117+
111118
Note: You can directly `return` a stream value inside event handlers alternatively which is recommended.
112119

113120
### `sendWebResponse(event, response)`

Diff for: docs/2.utils/98.advanced.md

+3
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ Make sure the status code is a valid HTTP status code.
6969
### `sanitizeStatusMessage(statusMessage)`
7070

7171
Make sure the status message is safe to use in a response.
72+
7273
Allowed characters: horizontal tabs, spaces or visible ascii characters: https://www.rfc-editor.org/rfc/rfc7230#section-3.1.2
7374

7475
<!-- /automd -->
@@ -130,7 +131,9 @@ Append CORS preflight headers to the response.
130131
### `handleCors(event, options)`
131132

132133
Handle CORS for the incoming request.
134+
133135
If the incoming request is a CORS preflight request, it will append the CORS preflight headers and send a 204 response.
136+
134137
If return value is `true`, the request is handled and no further action is needed.
135138

136139
### `isCorsOriginAllowed(origin, options)`

0 commit comments

Comments
 (0)