0
0
mirror of https://github.com/honojs/hono.git synced 2024-12-01 11:51:01 +01:00
hono/deno_dist/middleware/pretty-json/index.ts
2022-07-02 15:09:45 +09:00

15 lines
396 B
TypeScript

import type { Context } from '../../context.ts'
import type { Next } from '../../hono.ts'
type prettyOptions = {
space: number
}
export const prettyJSON = (options: prettyOptions = { space: 2 }) => {
return async (c: Context, next: Next) => {
const pretty = c.req.query('pretty') || c.req.query('pretty') === '' ? true : false
c.pretty(pretty, options.space)
await next()
}
}