Skip to content

docs: document middleware host and path routing#595

Open
kriszyp wants to merge 2 commits into
mainfrom
kris/document-host-routing-reference
Open

docs: document middleware host and path routing#595
kriszyp wants to merge 2 commits into
mainfrom
kris/document-host-routing-reference

Conversation

@kriszyp

@kriszyp kriszyp commented Jul 17, 2026

Copy link
Copy Markdown
Member

Summary

  • document built-in virtual-host and URL-prefix middleware routing
  • add host, urlPath, and middleware ordering fields to the HTTP API reference
  • clarify that scoped plugin configuration automatically applies routing to HTTP, WebSocket, and upgrade handlers
  • add the feature to the 5.2 release notes

Documents Middleware ordering and routing (HarperFast/harper#397).

Verification

  • npm run format:write
  • npm run format:check
  • npm run typecheck
  • npm run build (passes with one pre-existing broken-anchor warning in the 5.1 release notes)

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread reference/http/api.md Outdated
Comment thread reference/http/api.md Outdated
@github-actions
github-actions Bot temporarily deployed to pr-595 July 17, 2026 20:26 Inactive
@github-actions

Copy link
Copy Markdown

🚀 Preview Deployment

Your 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>
@github-actions

Copy link
Copy Markdown

🚀 Preview Deployment

Your preview deployment is ready!

🔗 Preview URL: https://preview.harper-documentation.harperfabric.com/pr-595

This preview will update automatically when you push new commits.

Comment thread reference/http/api.md
| `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 |

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Suggested change
| `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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants