docs: 修复文档中的API方法名和参数错误

- 更新quickstart.md中的Go版本要求为1.26
- 修复routing.md中使用setter方法而不是直接属性赋值
- 修复middleware.md中GetHeader为GetReqHeader
- 更新context.md移除未实现的binding标签
- 修复static-files.md中SetUnMatchFS的参数签名
- 修复advanced.md中SetMaxReader为SetGlobalMaxRequestBodySize
This commit is contained in:
WJQSERVER 2026-03-22 09:27:20 +08:00
parent c4c0160b5f
commit 8af515059a
6 changed files with 9 additions and 9 deletions

View file

@ -73,5 +73,5 @@ r.SetLoggerCfg(logConfig)
```go ```go
// 设置全局最大读取限制(例如 2MB // 设置全局最大读取限制(例如 2MB
r.SetMaxReader(2 << 20) r.SetGlobalMaxRequestBodySize(2 << 20)
``` ```

View file

@ -33,12 +33,12 @@ r.POST("/form_post", func(c *touka.Context) {
### JSON 绑定 ### JSON 绑定
Touka 提供了非常便捷的 JSON 绑定功能,它会自动解析请求体并填充到结构体中,同时进行基本的验证 Touka 提供了非常便捷的 JSON 绑定功能,它会自动解析请求体并填充到结构体中。
```go ```go
type LoginRequest struct { type LoginRequest struct {
User string `json:"user" binding:"required"` User string `json:"user"`
Password string `json:"password" binding:"required"` Password string `json:"password"`
} }
r.POST("/login", func(c *touka.Context) { r.POST("/login", func(c *touka.Context) {

View file

@ -53,7 +53,7 @@ func TimerMiddleware() touka.HandlerFunc {
```go ```go
func APIKeyAuth() touka.HandlerFunc { func APIKeyAuth() touka.HandlerFunc {
return func(c *touka.Context) { return func(c *touka.Context) {
apiKey := c.GetHeader("X-API-KEY") apiKey := c.GetReqHeader("X-API-KEY")
if apiKey != "secret-token" { if apiKey != "secret-token" {
// 验证失败,返回错误并中止后续逻辑 // 验证失败,返回错误并中止后续逻辑
c.JSON(http.StatusUnauthorized, touka.H{"error": "Invalid API Key"}) c.JSON(http.StatusUnauthorized, touka.H{"error": "Invalid API Key"})

View file

@ -4,7 +4,7 @@
## 安装 ## 安装
确保您的环境中已经安装了 Go 1.25 或更高版本。 确保您的环境中已经安装了 Go 1.26 或更高版本。
在您的项目目录中运行: 在您的项目目录中运行:

View file

@ -78,8 +78,8 @@ Touka 允许您自定义路由匹配的行为:
```go ```go
r := touka.New() r := touka.New()
r.RedirectTrailingSlash = true r.SetRedirectTrailingSlash(true)
r.HandleMethodNotAllowed = true r.SetHandleMethodNotAllowed(true)
``` ```
## 获取已注册路由信息 ## 获取已注册路由信息

View file

@ -49,7 +49,7 @@ func main() {
```go ```go
r := touka.New() r := touka.New()
r.SetUnMatchFS(http.Dir("./frontend/dist"), true) r.SetUnMatchFS(http.Dir("./frontend/dist"))
// API 路由 // API 路由
r.GET("/api/status", handleStatus) r.GET("/api/status", handleStatus)