0
0
mirror of https://github.com/honojs/hono.git synced 2024-11-21 18:18:57 +01:00

feat(context): added application json constant

This commit is contained in:
Marcel Overdijk 2024-09-03 17:59:02 +02:00
parent 350040470d
commit 31c6f0b063

View File

@ -328,6 +328,8 @@ interface ResponseInit {
export const TEXT_PLAIN = 'text/plain; charset=UTF-8'
export const APPLICATION_JSON = 'application/json; charset=UTF-8'
/**
* Sets the headers of a response.
*
@ -828,7 +830,7 @@ export class Context<
): JSONRespondReturn<T, U> => {
const body = JSON.stringify(object)
this.#preparedHeaders ??= {}
this.#preparedHeaders['content-type'] = 'application/json; charset=UTF-8'
this.#preparedHeaders['content-type'] = APPLICATION_JSON
/* eslint-disable @typescript-eslint/no-explicit-any */
return (
typeof arg === 'number' ? this.newResponse(body, arg, headers) : this.newResponse(body, arg)