Example websocket proof 5925307507322852050#103
Example websocket proof 5925307507322852050#103Suhaibinator merged 3 commits intowebsocket-supportfrom
Conversation
- Add `github.com/gorilla/websocket` dependency. - Create `examples/websocket/main.go` to demonstrate functional WebSocket support. - Include a client test in the example to verify REST and WebSocket endpoints. - Prove that `IsWebSocket: true` bypasses global timeouts.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## websocket-support #103 +/- ##
=====================================================
- Coverage 97.35% 95.28% -2.08%
=====================================================
Files 18 18
Lines 1740 1802 +62
=====================================================
+ Hits 1694 1717 +23
- Misses 34 66 +32
- Partials 12 19 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
💡 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".
| github.com/jinzhu/now v1.1.5 // indirect | ||
| github.com/pmezard/go-difflib v1.0.0 // indirect | ||
| golang.org/x/text v0.28.0 // indirect | ||
| go.yaml.in/yaml/v2 v2.4.3 // indirect | ||
| golang.org/x/text v0.32.0 // indirect |
There was a problem hiding this comment.
Correct typoed yaml module path in go.mod
The new indirect dependency on line 22 uses the module path go.yaml.in/yaml/v2, which appears to be a misspelling of the standard gopkg.in/yaml.v2. Go will try to resolve modules by domain name, so keeping the incorrect host causes go mod tidy or any build that resolves dependencies to fail with a module download error because go.yaml.in is not the published module path. Please switch to the canonical gopkg.in/yaml.v2 or drop the entry if unused.
Useful? React with 👍 / 👎.
* feat: Add WebSocket support by disabling timeouts for specific routes
This commit introduces the `IsWebSocket` flag to `RouteConfigBase`.
When set to true, this flag ensures that the router's global or sub-router
timeout configurations are ignored for the specific route, effectively
disabling the timeout middleware. This is necessary for long-lived
WebSocket connections that would otherwise be terminated by the timeout.
Changes:
- Modified `RouteConfigBase` in `pkg/router/config.go` to include `IsWebSocket`.
- Updated `registerSubRouter` in `pkg/router/router.go` to override timeout to 0 if `IsWebSocket` is true.
- Updated `RegisterRoute` in `pkg/router/route.go` to override timeout to 0 if `IsWebSocket` is true.
- Added `TestWebSocketRoute` in `pkg/router/websocket_test.go`.
- Updated `README.md` with documentation and usage examples.
* test: add more comprehensive tests for WebSocket support
Expanded the test suite to cover WebSocket support in both top-level
routers and sub-routers. This ensures that the `IsWebSocket` flag
correctly disables timeouts in all routing scenarios.
* add support for hijacking connections
* test: enhance WebSocket route tests for hijacking behavior
* test: add ResponseController tests for WebSocket route deadlines and full duplex
* Add minimal WebSocket example application (#102)
* feat: add minimal websocket example app
- Add `github.com/gorilla/websocket` dependency.
- Create `examples/websocket/main.go` to demonstrate functional WebSocket support.
- Include a client test in the example to verify REST and WebSocket endpoints.
- Prove that `IsWebSocket: true` bypasses global timeouts.
* refactor: simplify router initialization and update dependencies
---------
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: Suhaib <suhaib.abdulquddos@gmail.com>
* Example websocket proof 5925307507322852050 (#103)
* feat: add minimal websocket example app
- Add `github.com/gorilla/websocket` dependency.
- Create `examples/websocket/main.go` to demonstrate functional WebSocket support.
- Include a client test in the example to verify REST and WebSocket endpoints.
- Prove that `IsWebSocket: true` bypasses global timeouts.
* refactor: simplify router initialization and update dependencies
* fix: improve timeout handling in mutexResponseWriter to prevent race conditions
---------
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
* test: add race condition tests for timeout middleware
* test: add tests for Base64 and Base62 query parameter decoding errors
* test: add tests for CORS headers and logging in JSON error responses
* Rename IsWebSocket to DisableTimeout in RouteConfigBase (#104)
This is a breaking change that renames the `IsWebSocket` field to `DisableTimeout`
in `RouteConfigBase`. This new name better reflects the flag's purpose, which is
to disable the global or sub-router timeout for any long-lived connection, such
as WebSockets or Server-Sent Events (SSE).
Updates:
- `pkg/router/config.go`: Renamed field and updated comments.
- `pkg/router/route.go` & `pkg/router/router.go`: Updated logic to use `DisableTimeout`.
- `pkg/router/websocket_test.go`: Updated tests.
- `examples/websocket/main.go`: Updated example.
- `README.md`: Updated documentation.
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
* refactor: standardize formatting in WebSocket route configuration
---------
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: Suhaibinator <42899065+Suhaibinator@users.noreply.github.com>
No description provided.