-
We are considering implementing a conditional branch within Middleware that would call the next router if there is no match. Is there a way to implement the process of skipping the current router within Middleware? Here is the ideal code I have in mind right now. const checkVersion = (version: string) => {
return createMiddleware(async (c, next) => {
const apiVersion = c.req.header('api-version')
if (apiVersion !== version) {
return await next()
}
return await next()
})
}
app.get('/api', checkVersion('1.0.0'), (c) => {
return c.json({ version: 'world 1.0.0' })
})
app.get('/api', checkVersion('1.0.1'), (c) => {
return c.json({ version: 'world 1.0.1' })
})
app.get('/api', (c) => {
return c.json({ version: 'other' })
}) |
Beta Was this translation helpful? Give feedback.
Answered by
yusukebe
May 7, 2024
Replies: 1 comment 2 replies
-
Hi @Frog-kt The answer may be no. There is no feature to skip the next handler. |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
Frog-kt
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @Frog-kt
The answer may be no. There is no feature to skip the next handler.