Skip to content

Add websocket routing support#101

Open
Suhaibinator wants to merge 3 commits intomainfrom
codex/add-support-for-websockets
Open

Add websocket routing support#101
Suhaibinator wants to merge 3 commits intomainfrom
codex/add-support-for-websockets

Conversation

@Suhaibinator
Copy link
Owner

Summary

  • add a WebSocketRouteConfig and handler wrapper so websocket endpoints reuse the router middleware pipeline
  • document websocket usage and add README links for the new capability
  • cover websocket registration with an echo test case

Testing

  • go test ./...

Codex Task

@codecov
Copy link

codecov bot commented Dec 5, 2025

Codecov Report

❌ Patch coverage is 80.76923% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.45%. Comparing base (519a7e3) to head (cf3487c).

Files with missing lines Patch % Lines
pkg/router/websocket.go 56.52% 8 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #101      +/-   ##
==========================================
- Coverage   97.06%   96.45%   -0.61%     
==========================================
  Files          18       19       +1     
  Lines        2382     1777     -605     
==========================================
- Hits         2312     1714     -598     
+ Misses         57       48       -9     
- Partials       13       15       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +52 to +56
if upgrader == nil {
upgrader = defaultWebSocketUpgrader()
}

conn, err := upgrader.Upgrade(w, req, nil)

Choose a reason for hiding this comment

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

P1 Badge WebSocket upgrade fails when timeout middleware is enabled

Because WebSocket routes are run through wrapHandler, any non-zero Global/SubRouter/route timeout adds the timeout middleware, which replaces the http.ResponseWriter with mutexResponseWriter that does not implement http.Hijacker. The gorilla/websocket.Upgrader.Upgrade call here requires a Hijacker and will return websocket: response does not implement http.Hijacker, so WebSocket endpoints cannot upgrade once timeouts (or any similar middleware that wraps the writer) are configured.

Useful? React with 👍 / 👎.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments