-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinterfaces.go
More file actions
96 lines (72 loc) · 2.55 KB
/
Copy pathinterfaces.go
File metadata and controls
96 lines (72 loc) · 2.55 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package api
import (
"io"
"net/http"
)
// InterfaceSessionService is an interface to access session managing service
type InterfaceSessionService interface {
GetName() string
GC() error
New() (InterfaceSession, error)
Get(sessionID string, create bool) (InterfaceSession, error)
IsEmpty(sessionID string) bool
Touch(sessionID string) error
Close(sessionID string) error
GetKey(sessionID string, key string) interface{}
SetKey(sessionID string, key string, value interface{})
}
// InterfaceSession is an interface represents private storage for particular API request
type InterfaceSession interface {
GetID() string
Get(key string) interface{}
Set(key string, value interface{})
IsEmpty() bool
Touch() error
Close() error
}
// InterfaceRestService is an interface to interact with RESTFul API service
type InterfaceRestService interface {
GetName() string
Run() error
GetHandler(method string, resource string) FuncAPIHandler
GET(resource string, handler FuncAPIHandler)
PUT(resource string, handler FuncAPIHandler)
POST(resource string, handler FuncAPIHandler)
DELETE(resource string, handler FuncAPIHandler)
http.Handler
}
// InterfaceApplicationContextSupport is an interface to assign/get application context to object
type InterfaceApplicationContextSupport interface {
GetApplicationContext() InterfaceApplicationContext
SetApplicationContext(context InterfaceApplicationContext) error
}
// InterfaceApplicationContext is an interface representing context where current execution happens
type InterfaceApplicationContext interface {
GetRequest() interface{}
GetResponse() interface{}
GetSession() InterfaceSession
SetSession(session InterfaceSession) error
GetContextValues() map[string]interface{}
GetContextValue(key string) interface{}
SetContextValue(key string, value interface{})
GetResponseWriter() io.Writer
GetRequestArguments() map[string]string
GetRequestArgument(name string) string
GetRequestFiles() map[string]io.Reader
GetRequestFile(name string) io.Reader
GetRequestSettings() map[string]interface{}
GetRequestSetting(name string) interface{}
GetRequestContent() interface{}
GetRequestContentType() string
GetResponseContentType() string
SetResponseContentType(mimeType string) error
GetResponseSetting(name string) interface{}
SetResponseSetting(name string, value interface{}) error
GetResponseResult() interface{}
SetResponseResult(value interface{}) error
SetResponseStatus(code int)
SetResponseStatusBadRequest()
SetResponseStatusForbidden()
SetResponseStatusNotFound()
SetResponseStatusInternalServerError()
}