-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathframework.go
More file actions
178 lines (153 loc) · 2.88 KB
/
framework.go
File metadata and controls
178 lines (153 loc) · 2.88 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
package framework
import (
"net/http"
)
type Server interface {
SetHandler(http.Handler)
SetLogger(LogWriter)
SetAddr(string)
ListenAndServe() error
ListenAndServeTLS(string, string) error
}
type Error interface {
error
GetStatus() int
GetCode() string
GetType() string
GetMessage() string
Log(LogWriter)
}
type Config interface {
Get(string) Value
}
type Valuer interface {
Values() Values
SetValue(interface{}, interface{})
GetValue(interface{}) Value
Value(interface{}) interface{}
}
type ParamValuer interface {
Param(string) ParamValue
IsSet(string) bool
Params(...string) ParamValues
}
type Context interface {
LogWriter
Request
Response
Valuer
Operation() Operation
Locale() Locale
ID() int64
User() User
}
type Request interface {
Sessioner
ParamValuer
Path() string
Method() string
}
type Response interface {
http.ResponseWriter
}
type Operations interface {
Append(...Operation)
Set(...Operation)
Get() []Operation
GetByIndex(int) Operation
GetByName(string) Operation
Len() int
}
type ModelStore interface {
Get()
Create()
Edit()
Remove()
}
type Operation interface {
BuildPather
GetRoute() Route
GetName() string
GetMethods() []string
GetPath() string
GetFullPath() string
GetSchemes() []string
GetAccepts() []string
GetReturns() []string
// Param(string) Param
// Params(...string) Params
// BodyParam(string) Param
// BodyParams(...string) Params
// HeaderParam(string) Param
// HeaderParams(...string) Params
// PathParam(string) Param
// PathParams(...string) Params
// QueryParam(string) Param
// QueryParams(...string) Params
}
type Resource interface {
Create(Context) interface{}
Retrieve(Context) interface{}
Update(Context) interface{}
Delete(Context) interface{}
}
type Values map[interface{}]interface{}
func (vs *Values) Set(k interface{}, v interface{}) {
(*vs)[k] = v
}
func (vs *Values) Get(k interface{}) Value {
return &value{(*vs)[k]}
}
type Value interface {
Value() interface{}
Int() int
Int64() int64
Uint() uint
Uint64() uint64
Float32() float32
Float64() float64
String() string
Bool() bool
}
type Params interface {
ContainsFiles() bool
ContainsBodyParams() bool
}
type Param interface {
}
type ParamValues []ParamValue
func (pv *ParamValues) Append(v ...ParamValue) {
*pv = append(*pv, v...)
}
func (pv *ParamValues) Get(name string) ParamValue {
for _, v := range *pv {
if v.Name() == name {
return v
}
}
return nil
}
type ParamValue interface {
Value
Name() string
As() ValueType
RawString() string
IntE() (int, error)
Int64E() (int64, error)
UintE() (uint, error)
Uint64E() (uint64, error)
Float32E() (float32, error)
Float64E() (float64, error)
BoolE() (bool, error)
}
type BuildPather interface {
BuildPath(...interface{}) string
}
type Route interface {
BuildPather
GetPath() string
GetFullPath() string
GetSchemes() []string
GetAccepts() []string
GetReturns() []string
}