-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcenery.go
61 lines (50 loc) · 1.47 KB
/
cenery.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
package cenery
import "context"
type FileData struct {
FileData []byte `json:"fileData"`
FileName string `json:"fileName"`
FileSize int64 `json:"fileSize"`
FileContentType string `json:"fileContentType"`
}
type Ctx interface {
Params(key string, defaultValue ...string) string
QueryParam(key string, defaultValue ...string) string
BodyParser(out interface{}) error
FormFile(fileKey string) *FileData
FormFiles(fileKey string) *[]FileData
SendString(status int, data string) error
Send(status int, data []byte) error
SendJSON(status int, data interface{}) error
Request() Request
Response() Response
Next() error
}
type Request interface {
Body() []byte
SetBody(data []byte)
GetHeader(key string) string
SetHeader(key string, val string)
AddHeader(key string, val string)
}
type Response interface {
Body() []byte
SetBody(data []byte)
GetHeader(key string) string
SetHeader(key string, val string)
AddHeader(key string, val string)
}
type Handler = func(Ctx) error
type App interface {
Get(path string, handlers ...Handler)
Post(path string, handlers ...Handler)
Put(path string, handlers ...Handler)
Delete(path string, handlers ...Handler)
Head(path string, handlers ...Handler)
Options(path string, handlers ...Handler)
Connect(path string, handlers ...Handler)
Patch(path string, handlers ...Handler)
Trace(path string, handlers ...Handler)
Use(handlers ...Handler)
Listen(addr string) error
Shutdown(ctx context.Context) error
}