-
Notifications
You must be signed in to change notification settings - Fork 4
/
interface.go
56 lines (47 loc) · 1.01 KB
/
interface.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
package webapi
import (
"net/http"
)
type (
//Controller Controller statement
Controller interface {
Redirect(string, ...int)
SetCookies(...*http.Cookie)
Reply(int, ...interface{}) error
Write(int, []byte) error
ResponseHeader() http.Header
Context() *Context
}
)
type (
//Replyable Replyable for request reply
Replyable interface {
StatusCode() int
Data() interface{}
}
//Validator Validator for body and query structures
Validator interface {
Check() error
}
//ResponseWriter is a alternative for ResponseWriter Request
ResponseWriter interface {
Write(p []byte) (int, error)
Header() http.Header
WriteHeader(statusCode int)
}
//Serializer Serializer
Serializer interface {
Marshal(interface{}) ([]byte, error)
Unmarshal([]byte, interface{}) error
ContentType() string
}
//LogService Log service
LogService interface {
//Log with [datetime] prefix
Log(tpl string, args ...interface{})
//Write only text
Write(tpl string, args ...interface{})
//Stop exit
Stop()
}
)