Skip to content

Commit a142116

Browse files
authored
Merge branch 'main' into fix-faulty-duplicate-detection
2 parents ae3b2ba + 897fab0 commit a142116

54 files changed

Lines changed: 2050 additions & 1959 deletions

Some content is hidden

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

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111
strategy:
1212
matrix:
13-
go: [1.23, 1.24]
13+
go: [1.24, 1.25]
1414
name: Build & Test
1515
steps:
1616
- uses: actions/checkout@v4
@@ -21,7 +21,7 @@ jobs:
2121
- name: golangci-lint
2222
uses: golangci/golangci-lint-action@v8
2323
with:
24-
version: v2.1.6
24+
version: v2.9.0
2525
- run: go test -race -coverprofile=coverage.txt -covermode=atomic ./...
2626
- uses: codecov/codecov-action@v4
2727
with:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ A big thank you to our current & former sponsors!
109109
110110
# Install
111111

112-
Install via `go get`. Note that Go 1.23 or newer is required.
112+
Install via `go get`. Note that Go 1.24 or newer is required.
113113

114114
```sh
115115
# After: go mod init ...

README_CN.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
一个现代、简单、快速且灵活的微框架,用于在 OpenAPI 3 和 JSON Schema 支持的 Go 中构建 HTTP REST/RPC API。国际音标发音:[/'hjuːmɑ/](https://en.wiktionary.org/wiki/Wiktionary:International_Phonetic_Alphabet)。该项目的目标是提供:
2020

2121
- 拥有现有服务的团队逐步采用
22-
- 带上您自己的路由器(包括 Go 1.22+)、中间件和日志记录/指标
22+
- 带上您自己的路由器(包括 Go 1.24+)、中间件和日志记录/指标
2323
- 可扩展的 OpenAPI 和 JSON Schema 层来记录现有路由
2424
- 适合 Go 开发人员的现代 REST 或 HTTP RPC API 后端框架
2525
- [由OpenAPI 3.1](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md)[JSON Schema](https://json-schema.org/)描述
@@ -83,7 +83,7 @@
8383
8484
# 安装
8585

86-
通过安装`go get`。请注意,需要 Go 1.21 或更高版本。
86+
通过安装`go get`。请注意,需要 Go 1.24 或更高版本。
8787

8888
```sh
8989
# After: go mod init ...
@@ -150,7 +150,7 @@ func main() {
150150
```
151151

152152
> [!TIP]
153-
> 替换`chi.NewMux()``http.NewServeMux()``humachi.New``humago.New`以使用 Go 1.22+ 中的标准库路由器。只需确保其中列出了您的或更新的`go.mod`版本即可。`go 1.22`其他一切都保持不变!当你准备好时就切换。
153+
> 替换`chi.NewMux()``http.NewServeMux()``humachi.New``humago.New`以使用 Go 1.24+ 中的标准库路由器。只需确保其中列出了您的或更新的`go.mod`版本即可。`go 1.22`其他一切都保持不变!当你准备好时就切换。
154154
155155
你可以用 `go run greet.go` 测试它(可选地传递 '--port' 来更改默认值),并使用 [Restish](https://rest.sh/)(或 `curl`) 发出示例请求:
156156

README_JA.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
本プロジェクトの主な目的は以下の通りです:
3030

3131
- 既存サービスを持つチーム向けの段階的な導入
32-
- 好きなルーター(Go 1.22+対応含む)、ミドルウェア、ロギング/メトリクスを利用可能
32+
- 好きなルーター(Go 1.24+対応含む)、ミドルウェア、ロギング/メトリクスを利用可能
3333
- 既存ルートをドキュメント化できる拡張性の高いOpenAPI & JSON Schemaレイヤ
3434
- Go開発者のためのモダンなREST/HTTP RPC APIバックエンドフレームワーク
3535
- [OpenAPI 3.1](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md) & [JSON Schema](https://json-schema.org/)によるAPI記述
@@ -129,7 +129,7 @@
129129

130130
## インストール方法
131131

132-
`go get`でインストールできます。Go 1.21以降が必要です
132+
`go get`でインストールできます。Go 1.24以降が必要です
133133

134134
```sh
135135
# 事前に: go mod init ...
@@ -193,7 +193,7 @@ func main() {
193193
```
194194

195195
> **TIP:**
196-
> Go 1.22以降の標準ライブラリルーターを使う場合は`chi.NewMux()``http.NewServeMux()``humachi.New``humago.New`に変更してください。`go.mod``go`バージョンも1.22以上にする必要があります。それ以外は同じです。
196+
> Go 1.24以降の標準ライブラリルーターを使う場合は`chi.NewMux()``http.NewServeMux()``humachi.New``humago.New`に変更してください。`go.mod``go`バージョンも1.22以上にする必要があります。それ以外は同じです。
197197
198198
サーバー起動例:
199199
`go run greet.go`(ポート指定は`--port`でも可)

adapters/humabunrouter/humabunrouter_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,10 @@ func BenchmarkRawBunRouter(b *testing.B) {
177177
func(t reflect.Type, hint string) string {
178178
return t.Name()
179179
})
180-
schema := registry.Schema(reflect.TypeOf(GreetingInput{}), false, "")
180+
schema := registry.Schema(reflect.TypeFor[GreetingInput](), false, "")
181181

182-
strSchema := registry.Schema(reflect.TypeOf(""), false, "")
183-
numSchema := registry.Schema(reflect.TypeOf(0), false, "")
182+
strSchema := registry.Schema(reflect.TypeFor[string](), false, "")
183+
numSchema := registry.Schema(reflect.TypeFor[int](), false, "")
184184

185185
r := bunrouter.New()
186186

adapters/humachi/humachi_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,10 @@ func BenchmarkRawChi(b *testing.B) {
177177
func(t reflect.Type, hint string) string {
178178
return t.Name()
179179
})
180-
schema := registry.Schema(reflect.TypeOf(GreetingInput{}), false, "")
180+
schema := registry.Schema(reflect.TypeFor[GreetingInput](), false, "")
181181

182-
strSchema := registry.Schema(reflect.TypeOf(""), false, "")
183-
numSchema := registry.Schema(reflect.TypeOf(0), false, "")
182+
strSchema := registry.Schema(reflect.TypeFor[string](), false, "")
183+
numSchema := registry.Schema(reflect.TypeFor[int](), false, "")
184184

185185
r := chi.NewMux()
186186

adapters/humaecho/humaecho_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ func BenchmarkRawEcho(b *testing.B) {
9393
func(t reflect.Type, hint string) string {
9494
return t.Name()
9595
})
96-
schema := registry.Schema(reflect.TypeOf(GreetingInput{}), false, "")
96+
schema := registry.Schema(reflect.TypeFor[GreetingInput](), false, "")
9797

98-
strSchema := registry.Schema(reflect.TypeOf(""), false, "")
99-
numSchema := registry.Schema(reflect.TypeOf(0), false, "")
98+
strSchema := registry.Schema(reflect.TypeFor[string](), false, "")
99+
numSchema := registry.Schema(reflect.TypeFor[int](), false, "")
100100

101101
r := echo.New()
102102

adapters/humafiber/humafiber.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,9 @@ func (c *fiberWrapper) Header(name string) string {
9595
}
9696

9797
func (c *fiberWrapper) EachHeader(cb func(name, value string)) {
98-
c.orig.Request().Header.VisitAll(func(k, v []byte) {
98+
c.orig.Request().Header.All()(func(k, v []byte) bool {
9999
cb(string(k), string(v))
100+
return true // Keep iterating.
100101
})
101102
}
102103

adapters/humaflow/flow/flow.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func (m *Mux) Handle(pattern string, handler http.Handler, methods ...string) {
134134

135135
// Compile any regular expression patterns and add them to the
136136
// compiledRXPatterns map.
137-
for _, segment := range strings.Split(pattern, "/") {
137+
for segment := range strings.SplitSeq(pattern, "/") {
138138
if strings.HasPrefix(segment, ":") {
139139
_, rxPattern, containsRx := strings.Cut(segment, "|")
140140
if containsRx {
@@ -225,8 +225,8 @@ func (r *route) match(ctx context.Context, urlSegments []string) (context.Contex
225225
return ctx, true
226226
}
227227

228-
if strings.HasPrefix(routeSegment, ":") {
229-
key, rxPattern, containsRx := strings.Cut(strings.TrimPrefix(routeSegment, ":"), "|")
228+
if after, ok := strings.CutPrefix(routeSegment, ":"); ok {
229+
key, rxPattern, containsRx := strings.Cut(after, "|")
230230

231231
value, err := url.QueryUnescape(urlSegments[i])
232232
if err != nil {

adapters/humago/humago_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ func BenchmarkRawGo(b *testing.B) {
9292
func(t reflect.Type, hint string) string {
9393
return t.Name()
9494
})
95-
schema := registry.Schema(reflect.TypeOf(GreetingInput{}), false, "")
95+
schema := registry.Schema(reflect.TypeFor[GreetingInput](), false, "")
9696

97-
strSchema := registry.Schema(reflect.TypeOf(""), false, "")
98-
numSchema := registry.Schema(reflect.TypeOf(0), false, "")
97+
strSchema := registry.Schema(reflect.TypeFor[string](), false, "")
98+
numSchema := registry.Schema(reflect.TypeFor[int](), false, "")
9999

100100
r := http.NewServeMux()
101101

0 commit comments

Comments
 (0)