docs: document middleware host and path routing#595
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the documentation for Harper v5.2.0, introducing new middleware routing and ordering capabilities. It adds details and examples for configuring host and urlPath options across HTTP, WebSocket, and upgrade handlers, as well as explicit ordering options (name, before, after). The review feedback recommends clarifying that WsOptions and UpgradeOptions support all options from HttpOptions (including port configuration) rather than just routing and ordering options, to prevent ambiguity.
🚀 Preview DeploymentYour preview deployment is ready! 🔗 Preview URL: https://preview.harper-documentation.harperfabric.com/pr-595 This preview will update automatically when you push new commits. |
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
🚀 Preview DeploymentYour preview deployment is ready! 🔗 Preview URL: https://preview.harper-documentation.harperfabric.com/pr-595 This preview will update automatically when you push new commits. |
| | `before` | string | - | Run this entry before the named middleware entry | | ||
| | `after` | string | - | Run this entry after the named middleware entry | | ||
| | `urlPath` | string | - | Only handle requests whose pathname matches this prefix. Harper removes the prefix before passing the request to the handler. | | ||
| | `host` | string | - | Only handle requests whose `Host` header matches this virtual hostname | |
There was a problem hiding this comment.
Low: host matching is case-sensitive but the doc doesn't say so
matchesRoute() in server/middlewareChain.ts compares the Host header to route.host with a case-sensitive check (requestHost !== route.host), but HTTP Host headers are conventionally case-insensitive. A client sending Host: API.example.com against a configured host: api.example.com silently misses the routed chain and falls through to the default (or a 404) instead of matching. Worth calling out here since it fails silently in production.
Suggested fix:
| | `host` | string | - | Only handle requests whose `Host` header matches this virtual hostname | | |
| | `host` | string | - | Only handle requests whose `Host` header matches this virtual hostname (case-sensitive) | |
—
Generated by Barber AI
Summary
host,urlPath, and middleware ordering fields to the HTTP API referenceDocuments Middleware ordering and routing (HarperFast/harper#397).
Verification
npm run format:writenpm run format:checknpm run typechecknpm run build(passes with one pre-existing broken-anchor warning in the 5.1 release notes)