diff options
author | Matthew Heon <matthew.heon@gmail.com> | 2017-11-01 11:24:59 -0400 |
---|---|---|
committer | Matthew Heon <matthew.heon@gmail.com> | 2017-11-01 11:24:59 -0400 |
commit | a031b83a09a8628435317a03f199cdc18b78262f (patch) | |
tree | bc017a96769ce6de33745b8b0b1304ccf38e9df0 /vendor/github.com/go-zoo/bone/helper_17.go | |
parent | 2b74391cd5281f6fdf391ff8ad50fd1490f6bf89 (diff) | |
download | podman-a031b83a09a8628435317a03f199cdc18b78262f.tar.gz podman-a031b83a09a8628435317a03f199cdc18b78262f.tar.bz2 podman-a031b83a09a8628435317a03f199cdc18b78262f.zip |
Initial checkin from CRI-O repo
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
Diffstat (limited to 'vendor/github.com/go-zoo/bone/helper_17.go')
-rw-r--r-- | vendor/github.com/go-zoo/bone/helper_17.go | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/vendor/github.com/go-zoo/bone/helper_17.go b/vendor/github.com/go-zoo/bone/helper_17.go new file mode 100644 index 000000000..2e41ea4be --- /dev/null +++ b/vendor/github.com/go-zoo/bone/helper_17.go @@ -0,0 +1,39 @@ +// +build go1.7 + +/******************************** +*** Multiplexer for Go *** +*** Bone is under MIT license *** +*** Code by CodingFerret *** +*** github.com/go-zoo *** +*********************************/ + +package bone + +import ( + "context" + "net/http" +) + +// contextKeyType is a private struct that is used for storing bone values in net.Context +type contextKeyType struct{} + +// contextKey is the key that is used to store bone values in the net.Context for each request +var contextKey = contextKeyType{} + +// GetAllValues return the req PARAMs +func GetAllValues(req *http.Request) map[string]string { + values, ok := req.Context().Value(contextKey).(map[string]string) + if ok { + return values + } + + return map[string]string{} +} + +// serveMatchedRequest is an extension point for Route which allows us to conditionally compile for +// go1.7 and <go1.7 +func (r *Route) serveMatchedRequest(rw http.ResponseWriter, req *http.Request, vars map[string]string) { + ctx := context.WithValue(req.Context(), contextKey, vars) + newReq := req.WithContext(ctx) + r.Handler.ServeHTTP(rw, newReq) +} |