Zdravko Bozakov | 958d81c | 2019-12-13 22:09:48 +0100 | [diff] [blame] | 1 | package mux |
2 | |||||
3 | import ( | ||||
4 | "context" | ||||
5 | "net/http" | ||||
6 | ) | ||||
7 | |||||
8 | func contextGet(r *http.Request, key interface{}) interface{} { | ||||
9 | return r.Context().Value(key) | ||||
10 | } | ||||
11 | |||||
12 | func contextSet(r *http.Request, key, val interface{}) *http.Request { | ||||
13 | if val == nil { | ||||
14 | return r | ||||
15 | } | ||||
16 | |||||
17 | return r.WithContext(context.WithValue(r.Context(), key, val)) | ||||
18 | } |