From 87744524df50fd1ed0a4e3a576183a040bcc3fa2 Mon Sep 17 00:00:00 2001 From: caixw Date: Mon, 20 May 2024 13:00:43 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E6=9B=B4=E6=96=B0=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- header/header.go | 2 +- header/value.go | 26 ++++++++++---------------- router.go | 6 +++--- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/header/header.go b/header/header.go index 551d9ba..6995f81 100644 --- a/header/header.go +++ b/header/header.go @@ -24,7 +24,7 @@ const ( WantContentDigest = "Want-Content-Digest" ReprDigest = "Repr-Digest" WantReprDigest = "Want-Repr-Digest" - ContentType = "Content-Type" // 请求体的 MIME类型 (用于POST和PUT请求中) Content-Type: application/x-www-form-urlencoded + ContentType = "Content-Type" // 请求体的 MIME 类型 (用于 POST 和 PUT 请求中) Content-Type: application/x-www-form-urlencoded Date = "Date" // 发送该消息的日期和时间(按照 RFC7231 中定义的"超文本传输协议日期"格式来发送) Date: Tue, 15 Nov 1994 08:12:31 GMT Expect = "Expect" // 表明客户端要求服务器做出特定的行为 Expect: 100-continue From = "From" // 发起此请求的用户的邮件地址 From: user@example.com diff --git a/header/value.go b/header/value.go index b64d7bf..b3010c5 100644 --- a/header/value.go +++ b/header/value.go @@ -10,20 +10,14 @@ const ( NoCache = "no-cache" Identity = "identity" - // MessageHTTP TRACE 请求方法的 content-type 值 - MessageHTTP = "message/http" - - // MultipartFormData 表单提交类型 - MultipartFormData = "multipart/form-data" - - // FormData 普通的表单上传 - FormData = "application/x-www-form-urlencoded" - - EventStream = "text/event-stream" - Plain = "text/plain" - HTML = "text/html" - JSON = "application/json" - XML = "application/xml" - Javascript = "application/javascript" - OctetStream = "application/octet-stream" + MessageHTTP = "message/http" // MessageHTTP TRACE 请求方法的 content-type 值 + MultipartFormData = "multipart/form-data" // MultipartFormData 表单提交类型 + FormData = "application/x-www-form-urlencoded" // FormData 普通的表单上传 + EventStream = "text/event-stream" + Plain = "text/plain" + HTML = "text/html" + JSON = "application/json" + XML = "application/xml" + Javascript = "application/javascript" + OctetStream = "application/octet-stream" ) diff --git a/router.go b/router.go index d5e725a..c1ab3d7 100644 --- a/router.go +++ b/router.go @@ -277,7 +277,7 @@ func (p *PrefixOf[T]) URL(strict bool, pattern string, params map[string]string) // Prefix 在现有 PrefixOf 的基础上声明一个新的 [PrefixOf] 实例 // -// m 中间件函数,按顺序调用,会继承 p 的中间件并按在 m 之前; +// m 中间件函数,按顺序调用可参考 [Router.Use] 的说明; func (p *PrefixOf[T]) Prefix(prefix string, m ...types.MiddlewareOf[T]) *PrefixOf[T] { return p.router.Prefix(p.Pattern()+prefix, slices.Concat(m, p.middleware)...) } @@ -285,7 +285,7 @@ func (p *PrefixOf[T]) Prefix(prefix string, m ...types.MiddlewareOf[T]) *PrefixO // Prefix 声明一个 [PrefixOf] 实例 // // prefix 路由前缀字符串,可以为空; -// m 中间件函数,按顺序调用,会继承 r 的中间件并按在 m 之前; +// m 中间件函数,按顺序调用可参考 [Router.Use] 的说明; func (r *RouterOf[T]) Prefix(prefix string, m ...types.MiddlewareOf[T]) *PrefixOf[T] { return &PrefixOf[T]{router: r, pattern: prefix, middleware: slices.Clone(m)} } @@ -355,7 +355,7 @@ func (r *RouterOf[T]) Resource(pattern string, m ...types.MiddlewareOf[T]) *Reso // Resource 创建一个资源路由项 // // pattern 资源地址; -// m 中间件函数,按顺序调用,会继承 p 的中间件并按在 m 之前; +// m 中间件函数,按顺序调用可参考 [Router.Use] 的说明; func (p *PrefixOf[T]) Resource(pattern string, m ...types.MiddlewareOf[T]) *ResourceOf[T] { return p.router.Resource(p.Pattern()+pattern, slices.Concat(m, p.middleware)...) }