You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The text was updated successfully, but these errors were encountered:
antonpious
changed the title
Route separate followed by all the verbs and handler syntax
Route followed by required verbs and handler syntax
Jan 14, 2022
router.all('/foo',(ctx,next)=>{constallowed=['GET','POST']constisCorrect=allowed.includes(ctx.method)ctx.assert(ctx,405,"Ah nah man that's not right")})
As for optional path segments: yes, and if you need more complicated options you can use more Regex. Anything supported by path-to-regexp should be supported here, with obvious caveats like needing extra escapes for some characters.
@koa/router
version:10.1.1
koa
version:2.13.4
Code sample:
In express route if we want to match multiple verbs with the same route we could provide the following syntax
What is the equivalent syntax in Koa Router? Currently its expecting the route to be repeated.
Does the router support optional parameters?
The text was updated successfully, but these errors were encountered: