focalboard/server/context/context.go
Doug Lauder 66975bdfe9
First pass linter cleanup (#603)
* first pass linter cleanup

* address review comments
2021-06-21 11:21:42 +02:00

28 lines
560 B
Go

package context
import (
"context"
"net"
"net/http"
)
type contextKey struct {
key string
}
var connContextKey = &contextKey{"http-conn"}
// SetContextConn stores the connection in the request context.
func SetContextConn(ctx context.Context, c net.Conn) context.Context {
return context.WithValue(ctx, connContextKey, c)
}
// GetContextConn gets the stored connection from the request context.
func GetContextConn(r *http.Request) net.Conn {
value := r.Context().Value(connContextKey)
if value == nil {
return nil
}
return value.(net.Conn)
}