formacao
This commit is contained in:
+16
-2
@@ -1,4 +1,3 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
@@ -106,7 +105,7 @@ class HonoRequest {
|
||||
return headerData;
|
||||
}
|
||||
async parseBody(options) {
|
||||
return this.bodyCache.parsedBody ??= await (0, import_body.parseBody)(this, options);
|
||||
return (0, import_body.parseBody)(this, options);
|
||||
}
|
||||
#cachedBody = (key) => {
|
||||
const { bodyCache, raw } = this;
|
||||
@@ -170,6 +169,21 @@ class HonoRequest {
|
||||
arrayBuffer() {
|
||||
return this.#cachedBody("arrayBuffer");
|
||||
}
|
||||
/**
|
||||
* `.bytes()` parses the request body as a `Uint8Array`.
|
||||
*
|
||||
* @see {@link https://hono.dev/docs/api/request#bytes}
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* app.post('/entry', async (c) => {
|
||||
* const body = await c.req.bytes()
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
bytes() {
|
||||
return this.#cachedBody("arrayBuffer").then((buffer) => new Uint8Array(buffer));
|
||||
}
|
||||
/**
|
||||
* Parses the request body as a `Blob`.
|
||||
* @example
|
||||
|
||||
Reference in New Issue
Block a user