You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

25 lines
380 B

  1. // +build go1.7
  2. package mux
  3. import (
  4. "context"
  5. "net/http"
  6. )
  7. func contextGet(r *http.Request, key interface{}) interface{} {
  8. return r.Context().Value(key)
  9. }
  10. func contextSet(r *http.Request, key, val interface{}) *http.Request {
  11. if val == nil {
  12. return r
  13. }
  14. return r.WithContext(context.WithValue(r.Context(), key, val))
  15. }
  16. func contextClear(r *http.Request) {
  17. return
  18. }