From 8af515059a2e06cf1b82db314ccf1fe3ab794ff8 Mon Sep 17 00:00:00 2001 From: WJQSERVER <114663932+WJQSERVER@users.noreply.github.com> Date: Sun, 22 Mar 2026 09:27:20 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E4=BF=AE=E5=A4=8D=E6=96=87=E6=A1=A3?= =?UTF-8?q?=E4=B8=AD=E7=9A=84API=E6=96=B9=E6=B3=95=E5=90=8D=E5=92=8C?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 更新quickstart.md中的Go版本要求为1.26 - 修复routing.md中使用setter方法而不是直接属性赋值 - 修复middleware.md中GetHeader为GetReqHeader - 更新context.md移除未实现的binding标签 - 修复static-files.md中SetUnMatchFS的参数签名 - 修复advanced.md中SetMaxReader为SetGlobalMaxRequestBodySize --- docs/advanced.md | 2 +- docs/context.md | 6 +++--- docs/middleware.md | 2 +- docs/quickstart.md | 2 +- docs/routing.md | 4 ++-- docs/static-files.md | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/advanced.md b/docs/advanced.md index 613b180..345103d 100644 --- a/docs/advanced.md +++ b/docs/advanced.md @@ -73,5 +73,5 @@ r.SetLoggerCfg(logConfig) ```go // 设置全局最大读取限制(例如 2MB) -r.SetMaxReader(2 << 20) +r.SetGlobalMaxRequestBodySize(2 << 20) ``` diff --git a/docs/context.md b/docs/context.md index b67bec7..9dc962d 100644 --- a/docs/context.md +++ b/docs/context.md @@ -33,12 +33,12 @@ r.POST("/form_post", func(c *touka.Context) { ### JSON 绑定 -Touka 提供了非常便捷的 JSON 绑定功能,它会自动解析请求体并填充到结构体中,同时进行基本的验证。 +Touka 提供了非常便捷的 JSON 绑定功能,它会自动解析请求体并填充到结构体中。 ```go type LoginRequest struct { - User string `json:"user" binding:"required"` - Password string `json:"password" binding:"required"` + User string `json:"user"` + Password string `json:"password"` } r.POST("/login", func(c *touka.Context) { diff --git a/docs/middleware.md b/docs/middleware.md index f13de8e..a222437 100644 --- a/docs/middleware.md +++ b/docs/middleware.md @@ -53,7 +53,7 @@ func TimerMiddleware() touka.HandlerFunc { ```go func APIKeyAuth() touka.HandlerFunc { return func(c *touka.Context) { - apiKey := c.GetHeader("X-API-KEY") + apiKey := c.GetReqHeader("X-API-KEY") if apiKey != "secret-token" { // 验证失败,返回错误并中止后续逻辑 c.JSON(http.StatusUnauthorized, touka.H{"error": "Invalid API Key"}) diff --git a/docs/quickstart.md b/docs/quickstart.md index 6006e54..94f7433 100644 --- a/docs/quickstart.md +++ b/docs/quickstart.md @@ -4,7 +4,7 @@ ## 安装 -确保您的环境中已经安装了 Go 1.25 或更高版本。 +确保您的环境中已经安装了 Go 1.26 或更高版本。 在您的项目目录中运行: diff --git a/docs/routing.md b/docs/routing.md index 17897d8..039341f 100644 --- a/docs/routing.md +++ b/docs/routing.md @@ -78,8 +78,8 @@ Touka 允许您自定义路由匹配的行为: ```go r := touka.New() -r.RedirectTrailingSlash = true -r.HandleMethodNotAllowed = true +r.SetRedirectTrailingSlash(true) +r.SetHandleMethodNotAllowed(true) ``` ## 获取已注册路由信息 diff --git a/docs/static-files.md b/docs/static-files.md index 46954c8..a2138cd 100644 --- a/docs/static-files.md +++ b/docs/static-files.md @@ -49,7 +49,7 @@ func main() { ```go r := touka.New() -r.SetUnMatchFS(http.Dir("./frontend/dist"), true) +r.SetUnMatchFS(http.Dir("./frontend/dist")) // API 路由 r.GET("/api/status", handleStatus)