Any idea to default/enforce JSON responses? #2935
Answered
by
EdamAme-x
MaximeBernard
asked this question in
Q&A
-
Hi, I'm coming from koa, played with fastify and they both return JSON responses by default. I was wondering if I could do something similar in Hono? My ideal would have been a const app = new Hono({ jsonOnly: true }); But maybe I can do this with a middleware? Out of curiosity, why do you need to |
Beta Was this translation helpful? Give feedback.
Answered by
EdamAme-x
Jun 11, 2024
Replies: 1 comment 4 replies
-
hi @MaximeBernard |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hmm...
I think that is possible.
But, we have some breaking problems.
That way of writing is similar to elysia.js.
In Hono, that kind of return is impossible due to types.
Perhaps you can do it by playing with the response in middleware, but I don't recommend it because of the types issue.