Skip to content

Commit

Permalink
docs: 更新文档
Browse files Browse the repository at this point in the history
  • Loading branch information
caixw committed May 20, 2024
1 parent 1b632f6 commit 8774452
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 20 deletions.
2 changes: 1 addition & 1 deletion header/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 10 additions & 16 deletions header/value.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
6 changes: 3 additions & 3 deletions router.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,15 +277,15 @@ 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)...)
}

// 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)}
}
Expand Down Expand Up @@ -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)...)
}
Expand Down

0 comments on commit 8774452

Please sign in to comment.