Skip to content

Commit 8c9fd44

Browse files
authored
ci: bump Go version to 1.27 (#118)
* ci: bump Go version to 1.27 Update Go version to 1.27 in GitHub Actions workflows and project documentation. Also update loop syntax in tests to use the `for range` idiom. * refactor: unify route registration * Add custom rune scroll codec example * docs: update docs for recursive route group architecture - Document the new recursive `RouteGroup` tree replacing the old SubRouter hierarchy. - Update middleware execution order to Recovery → Auth → RateLimit → Global → groups → Route → Timeout → Handler. - Replace imperative registration methods with `r.Route()` and `group.Route()`. - Update README description to highlight recursive route groups and type-safe handling. * refactor: finalize typed route groups * test: cover router edge cases
1 parent 5821dd7 commit 8c9fd44

96 files changed

Lines changed: 4213 additions & 4623 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/tests.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ubuntu-latest
1313
strategy:
1414
matrix:
15-
go-version: ['1.26.3']
15+
go-version: ['1.27']
1616
os: [ubuntu-latest, macos-latest, windows-latest]
1717
fail-fast: true
1818

@@ -60,11 +60,11 @@ jobs:
6060
- name: Set up Go
6161
uses: actions/setup-go@v4
6262
with:
63-
go-version: '1.26.3'
63+
go-version: '1.27.0'
6464
cache: true
6565

6666
- name: Install golangci-lint
67-
run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
67+
run: go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.13.0
6868

6969
- name: Run golangci-lint
7070
run: golangci-lint run --timeout=5m
@@ -74,7 +74,7 @@ jobs:
7474
runs-on: ubuntu-latest
7575
strategy:
7676
matrix:
77-
go-version: ['1.26.3']
77+
go-version: ['1.27.0']
7878
os: [ubuntu-latest, macos-latest, windows-latest]
7979

8080
steps:
@@ -100,7 +100,7 @@ jobs:
100100
- name: Set up Go
101101
uses: actions/setup-go@v4
102102
with:
103-
go-version: '1.26.3'
103+
go-version: '1.27.0'
104104
cache: true
105105

106106
- name: Run benchmarks
@@ -116,7 +116,7 @@ jobs:
116116
- name: Set up Go
117117
uses: actions/setup-go@v4
118118
with:
119-
go-version: '1.26.3'
119+
go-version: '1.27.0'
120120
cache: true
121121

122122
- name: Build simple example

AGENTS.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ golangci-lint run
4141

4242
## Architecture Overview
4343

44-
SRouter is a high-performance HTTP router framework built on `julienschmidt/httprouter` with Go generics support (requires Go 1.26.0+). The codebase follows a layered architecture with clear separation of concerns.
44+
SRouter is a high-performance HTTP router framework built on `julienschmidt/httprouter` with Go generics support (requires Go 1.27+). The codebase follows a layered architecture with clear separation of concerns.
4545

4646
### Core Type Parameters
4747
Throughout the codebase, `T` represents the UserID type (must be comparable) and `U` represents the User object type. These generic parameters enable type-safe authentication and context management.
@@ -60,12 +60,12 @@ Throughout the codebase, `T` represents the UserID type (must be comparable) and
6060
3. Client IP extraction based on IPConfig
6161
4. Metrics and trace ID injection
6262
5. httprouter path matching
63-
6. Middleware chain execution (Recovery → Auth → RateLimit → Route-specificGlobal → Timeout → Handler)
63+
6. Middleware chain execution (Recovery → Auth → RateLimit → Globalouter groups → inner groups → Route → Timeout → Handler)
6464
7. Generic handler marshaling/unmarshaling (if applicable)
6565

6666
### Key Design Patterns
6767
- **Middleware Chain**: Composable middleware with configurable execution order
68-
- **Configuration Hierarchy**: Global → SubRouter → Route with cascading overrides
68+
- **Route Tree**: `Router.Group` creates recursive `RouteGroup` handles; policy inherits Global → outer groups → inner groups → Route
6969
- **Generic Routes**: Type-safe handlers with automatic codec-based marshaling
7070
- **Context Wrapper**: Single SRouterContext avoids deep context nesting
7171

@@ -91,13 +91,15 @@ Flexible rate limiting with strategies:
9191
Uses Uber's ratelimit library with leaky bucket algorithm.
9292

9393
### Generic Route Registration
94-
Generic routes should be registered using `NewGenericRouteDefinition` within SubRouterConfig.Routes for declarative configuration:
94+
Generic `RouteConfig` values can be registered directly on a `Router` or `RouteGroup`:
9595
```go
96-
router.NewGenericRouteDefinition[ReqType, RespType, UserIDType, UserType](
97-
router.RouteConfig[ReqType, RespType]{...}
98-
)
96+
router.RouteConfig[ReqType, RespType]{...}
9997
```
10098

99+
Call `r.Route(route)` for root routes or retain a group handle and call
100+
`group.Route(route)`. Both methods accept standard and typed routes. Route trees
101+
freeze at `Build` or the first request.
102+
101103
### Context Access
102104
Always use scontext package helpers for type-safe context access:
103105
```go
@@ -115,4 +117,4 @@ Generic routes automatically store handler errors in the request context, allowi
115117
- Error metrics collection
116118

117119
### Trace ID Generation
118-
Enable trace ID generation by setting `TraceIDBufferSize > 0` in RouterConfig. This creates a background ID generator for efficient UUID generation and automatic request correlation.
120+
Enable trace ID generation by setting `TraceIDBufferSize > 0` in RouterConfig. This creates a background ID generator for efficient UUID generation and automatic request correlation.

CLAUDE.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ golangci-lint run
4141

4242
## Architecture Overview
4343

44-
SRouter is a high-performance HTTP router framework built on `julienschmidt/httprouter` with Go generics support (requires Go 1.26.0+). The codebase follows a layered architecture with clear separation of concerns.
44+
SRouter is a high-performance HTTP router framework built on `julienschmidt/httprouter` with Go generics support (requires Go 1.27+). The codebase follows a layered architecture with clear separation of concerns.
4545

4646
### Core Type Parameters
4747
Throughout the codebase, `T` represents the UserID type (must be comparable) and `U` represents the User object type. These generic parameters enable type-safe authentication and context management.
@@ -60,12 +60,12 @@ Throughout the codebase, `T` represents the UserID type (must be comparable) and
6060
3. Client IP extraction based on IPConfig
6161
4. Metrics and trace ID injection
6262
5. httprouter path matching
63-
6. Middleware chain execution (Recovery → Auth → RateLimit → Route-specificGlobal → Timeout → Handler)
63+
6. Middleware chain execution (Recovery → Auth → RateLimit → Globalouter groups → inner groups → Route → Timeout → Handler)
6464
7. Generic handler marshaling/unmarshaling (if applicable)
6565

6666
### Key Design Patterns
6767
- **Middleware Chain**: Composable middleware with configurable execution order
68-
- **Configuration Hierarchy**: Global → SubRouter → Route with cascading overrides
68+
- **Route Tree**: `Router.Group` creates recursive `RouteGroup` handles; policy inherits Global → outer groups → inner groups → Route
6969
- **Generic Routes**: Type-safe handlers with automatic codec-based marshaling
7070
- **Context Wrapper**: Single SRouterContext avoids deep context nesting
7171

@@ -91,13 +91,15 @@ Flexible rate limiting with strategies:
9191
Uses Uber's ratelimit library with leaky bucket algorithm.
9292

9393
### Generic Route Registration
94-
Generic routes should be registered using `NewGenericRouteDefinition` within SubRouterConfig.Routes for declarative configuration:
94+
Generic `RouteConfig` values can be registered directly on a `Router` or `RouteGroup`:
9595
```go
96-
router.NewGenericRouteDefinition[ReqType, RespType, UserIDType, UserType](
97-
router.RouteConfig[ReqType, RespType]{...}
98-
)
96+
router.RouteConfig[ReqType, RespType]{...}
9997
```
10098

99+
Call `r.Route(route)` for root routes or retain a group handle and call
100+
`group.Route(route)`. Both methods accept standard and typed routes. Route trees
101+
freeze at `Build` or the first request.
102+
101103
### Context Access
102104
Always use scontext package helpers for type-safe context access:
103105
```go
@@ -115,4 +117,4 @@ Generic routes automatically store handler errors in the request context, allowi
115117
- Error metrics collection
116118

117119
### Trace ID Generation
118-
Enable trace ID generation by setting `TraceIDBufferSize > 0` in RouterConfig. This creates a background ID generator for efficient UUID generation and automatic request correlation.
120+
Enable trace ID generation by setting `TraceIDBufferSize > 0` in RouterConfig. This creates a background ID generator for efficient UUID generation and automatic request correlation.

0 commit comments

Comments
 (0)