adds ability to set an env in the app context

This commit is contained in:
2018-01-04 07:32:15 +00:00
parent 95400f4e69
commit 2d05e42555
7 changed files with 26 additions and 11 deletions
+7 -1
View File
@@ -11,7 +11,7 @@ import (
"github.com/gorilla/mux"
)
func NewContext(r Route, res http.ResponseWriter, req *http.Request) *DefaultContext {
func NewContext(r Route, res http.ResponseWriter, req *http.Request, env string) *DefaultContext {
data := make(map[string]interface{})
data["path"] = r.Path
@@ -26,6 +26,7 @@ func NewContext(r Route, res http.ResponseWriter, req *http.Request) *DefaultCon
request: req,
params: params,
data: data,
env: env,
}
}
@@ -36,6 +37,7 @@ type DefaultContext struct {
params url.Values
contentType string
data map[string]interface{}
env string
}
// Response returns the original Response for the request.
@@ -111,3 +113,7 @@ func (d *DefaultContext) Redirect(status int, url string) error {
http.Redirect(d.Response(), d.Request(), url, status)
return nil
}
func (d *DefaultContext) Env() string {
return d.env
}