Update Go version requirement to 1.26.0 and refactor auth/context APIs#112
Merged
Conversation
Audit docs/README against the code and fix drift accumulated since recent features (Overrides/RouteOverrides, GlobalAuthToken, WebSocket DisableTimeout, ProtoCodec changes, removal of CORS middleware, new(expr) usage). - Bump documented Go version to 1.26.0 (matches go.mod) across README, getting-started, AGENTS.md, CLAUDE.md - Fix NewRouter auth function signatures to use pointer user object (*U) in README quick-start and getting-started example - Correct middleware execution order (Recovery outermost, Trace, Auth, RateLimit, route/sub-router, global, Timeout, base handler) - Document DisableTimeout on RouteConfigBase and add the websocket example - Replace removed/non-existent API references: CORS middleware -> CORSConfig, NewBasicUserAuthProvider -> BasicUserAuthProvider literal, add CreateTraceMiddleware type params, drop the obsolete AuthLevel Ptr helper - Correct metrics docs: latency Histogram tagged by route, throughput is a request-body-bytes Counter, QPS/errors tags; note MiddlewareFactory is not currently consumed by the router - Fix Flags type (map[string]bool), WithUser/WithFlag usage, scontext import, RouteConfig Sanitizer field, Empty SourceType, ExceededHandler type, MaxBodySize (was MaxBodyBytes), CORSConfig MaxAge type, context-management httprouter import https://claude.ai/code/session_01X4xFQGLsqaGriQuH121Kv9
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #112 +/- ##
=======================================
Coverage 97.57% 97.57%
=======================================
Files 18 18
Lines 1935 1935
=======================================
Hits 1888 1888
Misses 35 35
Partials 12 12 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR updates the minimum Go version requirement from 1.24.0 to 1.26.0 and introduces significant API changes to authentication and context handling. The authentication function now returns a pointer to the user object instead of the object itself, improving memory efficiency and consistency with the context management system. Documentation has been comprehensively updated to reflect these changes and clarify several implementation details.
Key Changes
Authentication API Refactoring
authFunctionnow returns(*UserObjectType, bool)instead of(UserObjectType, bool)SRouterContext(as pointers)Context Management Improvements
SRouterContext.Flagsnow storesmap[string]boolinstead ofmap[string]anyAuthenticationBoolmiddleware)context.WithValue()APIDocumentation Clarifications
MiddlewareFactoryis reserved but not currently consumed; SRouter always builds its own metrics middleware fromCollectorRouterConfig.CORSConfig, not as standalone middlewarepkg/codec/codec.goinstead ofpkg/router/config.go[T comparable, U any]Configuration Updates
DisableTimeoutfield documentation for long-lived connections (WebSockets, etc.)Emptysource type that acts as a no-op for decodingnew(router.AuthRequired)is the standard way to set auth levelsMinor Fixes
pkg/middlewaretopkg/scontext)RegisterGenericRoute)Implementation Details
https://claude.ai/code/session_01X4xFQGLsqaGriQuH121Kv9