github.com/olivierlemoal/gophish@v0.9.0/context/context.go (about)

     1  // +build go1.7
     2  
     3  package context
     4  
     5  import (
     6  	"net/http"
     7  
     8  	"context"
     9  )
    10  
    11  // Get retrieves a value from the request context
    12  func Get(r *http.Request, key interface{}) interface{} {
    13  	return r.Context().Value(key)
    14  }
    15  
    16  // Set stores a value on the request context
    17  func Set(r *http.Request, key, val interface{}) *http.Request {
    18  	if val == nil {
    19  		return r
    20  	}
    21  
    22  	return r.WithContext(context.WithValue(r.Context(), key, val))
    23  }
    24  
    25  // Clear is a null operation, since this is handled automatically in Go > 1.7
    26  func Clear(r *http.Request) {
    27  	return
    28  }