-
Notifications
You must be signed in to change notification settings - Fork 1
/
iface.go
54 lines (44 loc) · 868 Bytes
/
iface.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
package binder
import (
"errors"
"net/textproto"
"github.com/labstack/echo/v4"
"github.com/popeyeio/handy"
)
const (
memoryMax = 1 << 25
TagHeader = "header"
TagParam = "param"
TagForm = "form"
TagJSON = "json"
TagXML = "xml"
TagProtobuf = "protobuf"
TagMsgpack = "msgpack"
TagYAML = "yaml"
TagEnv = "env"
TagCookie = "cookie"
)
var (
ErrInvalidType = errors.New("invalid type")
)
type Binder interface {
Bind(echo.Context, interface{}) error
}
type BeforeBinder interface {
BeforeBind(echo.Context) error
}
type AfterBinder interface {
AfterBind(echo.Context) error
}
func canonicalKey(key string, canonical bool) string {
if !canonical {
return key
}
return textproto.CanonicalMIMEHeaderKey(key)
}
func convertValue(value string) string {
if !handy.IsEmptyStr(value) {
return value
}
return "0"
}