Mono repo -> Master (#22553)
Combines the following repositories into one: https://github.com/mattermost/mattermost-server https://github.com/mattermost/mattermost-webapp https://github.com/mattermost/focalboard https://github.com/mattermost/mattermost-plugin-playbooks
Этот коммит содержится в:
32
server/boards/api/context.go
Обычный файл
32
server/boards/api/context.go
Обычный файл
@@ -0,0 +1,32 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type contextKey int
|
||||
|
||||
const (
|
||||
httpConnContextKey contextKey = iota
|
||||
sessionContextKey
|
||||
)
|
||||
|
||||
// SetContextConn stores the connection in the request context.
|
||||
func SetContextConn(ctx context.Context, c net.Conn) context.Context {
|
||||
return context.WithValue(ctx, httpConnContextKey, c)
|
||||
}
|
||||
|
||||
// GetContextConn gets the stored connection from the request context.
|
||||
func GetContextConn(r *http.Request) net.Conn {
|
||||
value := r.Context().Value(httpConnContextKey)
|
||||
if value == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return value.(net.Conn)
|
||||
}
|
||||
Ссылка в новой задаче
Block a user