added doormen ownership

This commit is contained in:
didier amyot committed 2015-06-14 23:21:42 -04:00
1 parent f0628e4682
commit f7a8d416c1
27 files changed
+489 -126

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
package api
import (
"github.com/gorilla/context"
"net/http"
)
const userKey = "user"
func GetUser(req *http.Request) string {
if rv := context.Get(req, userKey); rv != nil {
return rv.(string)
}
return ""
}
func SetUser(req *http.Request, user string) {
context.Set(req, userKey, user)
}
func AuthenticationMiddleware(h http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, req *http.Request) {
query := req.URL.Query()
user := query.Get("user")
SetUser(req, user)
h(w, req)
context.Clear(req)
}
}