working commit
This commit is contained in:
@@ -22,6 +22,8 @@ type Context struct {
|
||||
Request *http.Request
|
||||
Writer http.ResponseWriter
|
||||
PathMap map[string]string
|
||||
Bools map[string]bool
|
||||
Strings map[string]string
|
||||
StatusCode int
|
||||
}
|
||||
|
||||
@@ -32,10 +34,31 @@ func NewContext(writer http.ResponseWriter, request *http.Request) *Context {
|
||||
Request: request,
|
||||
Ctx: ctx,
|
||||
PathMap: make(map[string]string),
|
||||
Bools: make(map[string]bool),
|
||||
Strings: make(map[string]string),
|
||||
}
|
||||
return rctx
|
||||
}
|
||||
|
||||
// Aux maps
|
||||
func (rctx *Context) SetBool(key string, value bool) {
|
||||
rctx.Bools[key] = value
|
||||
}
|
||||
|
||||
func (rctx *Context) GetBool(key string) (bool, bool) {
|
||||
exists, value := rctx.Bools[key]
|
||||
return exists, value
|
||||
}
|
||||
|
||||
func (rctx *Context) SetString(key string, value string) {
|
||||
rctx.Strings[key] = value
|
||||
}
|
||||
|
||||
func (rctx *Context) GetString(key string) (string, bool) {
|
||||
value, exists := rctx.Strings[key]
|
||||
return value, exists
|
||||
}
|
||||
|
||||
// Request
|
||||
func (rctx *Context) GetSubpath(key string) (string, bool) {
|
||||
value, exists := rctx.PathMap[key]
|
||||
|
||||
Reference in New Issue
Block a user