npm install swork-router
yarn add swork-router
get | post | put | patch | delete | head | options | all
Create a route using the HTTP verb as your method name such as
router.post(...). In addition,
all is available to match on all HTTP verbs.
You are able to pass in a single path or an array of paths with the middleware to be invoked when a path is matched.
Every verb method returns the router instance allowing chaining of path handlers.
Route paths must start with a slash and end without one. Paths are translated to regular expressions using path-to-regexp. As a result, query strings are not evaluated when matching requests.
use allows the nesting of routers. This is useful when building a routes in a separate module.
Routes can be prefixed at the router level.
;router.get"/", ...; // responds to "/foos"router.put"/:id", ...; // responds to "/foos/:id"
Alternate origins can be used but default to
configuration.origin from swork.
Named route parameters are captured and added to