New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transform request body #2467
Comments
If you would like to do that in the meantime, you can use |
As @NicoPlyley said, we can use |
@yusukebe If possible to transform a body before getting to route all route can use |
This way is not recommended because this API is for internal usage, but you can make it with the code: app.use('*', async (c, next) => {
const data = await c.req.json()
//
c.req.bodyCache.json = 'transformeddata'
await next()
})
app.post('/', async (c) => {
const data = await c.req.json()
return c.json(data)
}) |
Can internal |
No. Basically, the Request body should be immutable, and we don't want to add more methods to the |
What is the feature you are proposing?
Routes get request body with functions like
await c.req.json()
. In middleware you should be able to intercept and change the value the route gets with something likec.req.setJson(someTransformMethod(await c.req.json()))
.The text was updated successfully, but these errors were encountered: