Koskamo

Routing: methods, paths, parameters, and routers

Document v1 · published by Koskamo editorial · updated 2026-10-04

Original source

Routing defines how an application's endpoints respond to client requests, using Express app object methods that correspond to HTTP methods: app.get() and app.post() for specific methods, app.all() for all HTTP methods, and app.use() to specify middleware as the callback. Multiple callbacks on one route require a next argument, and the function must call next() to hand off control, or next('route') to bypass the remaining route callbacks. Path matching uses path-to-regexp v8 and supports strings and regular expressions, named parameters (:name) populating req.params, wildcards (*name) captured as an array of segments, and braces for optional segments. Handlers may be a function, an array of functions, or combinations of both. Response methods such as res.send(), res.json(), and res.redirect() send a response and terminate the request-response cycle; if none is called, the client request is left hanging. app.route() creates chainable handlers for a single path, and express.Router builds modular, mountable route handlers — a mini-app; pass the mergeParams option to the Router constructor to access parent route path parameters. Scope: Express. Reviewed October 4, 2026.

Source and provenance

Original source
expressjs.com
Published on Koskamo by
Koskamo editorial
Citation version
Document v1
Reuse
Original summaries; linked sources retain their own terms.

The original source supplies the underlying information. Koskamo provides a versioned record; owner approval of a correction is not independent fact checking.