-
Notifications
You must be signed in to change notification settings - Fork 0
/
const.go
72 lines (54 loc) · 1.7 KB
/
const.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package zeroapi
import (
"net/http"
)
const (
// MethodGet 请求指定的页面信息,并返回实体主体
MethodGet = http.MethodGet
// MethodPost 向指定资源提交数据处理请求,数据包含在请求体中
MethodPost = http.MethodPost
// MethodPut 从客户端向服务器传送数据,取代指定文档的内容。替换
MethodPut = http.MethodPut
// MethodDelete 请求服务器删除指定数据
MethodDelete = http.MethodDelete
// MethodConn 用于代理
MethodConn = http.MethodConnect
// MethodHead 类似于 GET 请求,但响应没有具体的内容,用于获取报头
MethodHead = http.MethodHead
// MethodPatch 类似于 PUT,但可能只包含部分数据。修改部分数据
MethodPatch = http.MethodPatch
// MethodOptions ..
MethodOptions = http.MethodOptions
// MethodTrace 回显服务器收到的请求
MethodTrace = http.MethodTrace
// MethodAny 同时注册 GET, POST, PUT, DELETE, HEAD, PATCH, OPTIONS
MethodAny = "ANY"
)
// AllMethods 所有 HTTP Method
func AllMethods() []string {
return []string{
MethodGet,
MethodPost,
MethodPut,
MethodDelete,
MethodConn,
MethodHead,
MethodPatch,
MethodOptions,
MethodTrace,
}
}
type (
// Handler 处理函数
Handler func(ctx Context)
// HookHandler 钩子处理函数,用于中间件开发,响应 ctx.afters, ctx.ends
HookHandler func() error
// RouterValidator 验证函数
RouterValidator func(s string) bool
// CookieEncodeHandler cookie 编码与解码函数
CookieEncodeHandler func(s string) string
// CookieDecodeHandler cookie 编码与解码函数
CookieDecodeHandler func(s string) (string, error)
// CookieOption cookie 选项
CookieOption func(cookie *http.Cookie) error
)