Add landing page for non-MoQ clients accessing relay#1280
Add landing page for non-MoQ clients accessing relay#1280
Conversation
Visiting a relay directly in a browser previously returned "Request method must be `CONNECT`" from axum's WebSocketUpgrade extractor, which is confusing for anyone who stumbles onto a relay URL. Add an HTML landing page that explains the server is a moq-relay instance and points at https://moq.dev. The page is served as the axum router fallback (e.g. for GET /) and also whenever the WebSocket upgrade route receives a non-upgrade request, so every plain HTTP path now returns the landing page instead of an internal rejection message. https://claude.ai/code/session_01FMvy3oWhasZwmxnCcch8tN
WalkthroughAdded a landing page HTML file for the moq-relay service. Modified web.rs to register a fallback handler that serves the landing page for unmatched routes, and updated websocket.rs to accept extraction results instead of direct types. When any extraction fails in the websocket handler—such as non-WebSocket requests or invalid parameters—the landing page is returned instead of propagating an error. The landing page includes metadata, styling, a heading, descriptive text, and a link to moq.dev. 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@rs/moq-relay/src/landing.html`:
- Around line 62-64: The landing page currently only links to https://moq.dev;
update the paragraph that renders the link (the <p> element containing "See
https://moq.dev for more info.") to also include the specification URL
referenced in the PR objective by adding an additional anchor (or appending the
spec link) alongside the moq.dev link so users can access both the site and the
spec; modify the content of that <p> to include the spec link text and URL.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c0a124ed-4aec-4d5e-9734-6b161ffcc967
📒 Files selected for processing (3)
rs/moq-relay/src/landing.htmlrs/moq-relay/src/web.rsrs/moq-relay/src/websocket.rs
| <p> | ||
| See <a href="https://moq.dev">https://moq.dev</a> for more info. | ||
| </p> |
There was a problem hiding this comment.
Add the spec link called out in the PR objective.
The page only points users at moq.dev right now, so the “spec + site” guidance described for this feature is still incomplete.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@rs/moq-relay/src/landing.html` around lines 62 - 64, The landing page
currently only links to https://moq.dev; update the paragraph that renders the
link (the <p> element containing "See https://moq.dev for more info.") to also
include the specification URL referenced in the PR objective by adding an
additional anchor (or appending the spec link) alongside the moq.dev link so
users can access both the site and the spec; modify the content of that <p> to
include the spec link text and URL.
Summary
This PR adds a user-friendly landing page that is served when a regular web browser or non-MoQ client accesses the relay directly, replacing generic error responses with informative guidance.
Key Changes
landing.htmlwith styled informational content explaining that the relay is a MoQ service and directing users to https://moq.dev for more informationserve_landing) that catches all unmatched routes and serves the landing page with a 404 status codeserve_wsto gracefully handle extraction failures (WebSocket upgrade, path, and query rejections) by serving the landing page instead of exposing internal error messageslanding_response()utility function to generate consistent landing page responsesImplementation Details
Resulttypes for its extractors, allowing it to detect when a plain HTTP request arrives and serve the landing page instead of letting Axum's WebSocket extractor reject the request with a technical error messageinclude_str!()for efficient servinghttps://claude.ai/code/session_01FMvy3oWhasZwmxnCcch8tN