Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 

19 rader
315 B

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