Documentation ¶
Index ¶
- Constants
- Variables
- func APILoggerMiddleware(logFile string) func(http.Handler) http.Handler
- func DefaultLoggerMiddleware(logFile string) func(http.Handler) http.Handler
- func GetMiddlewareLogger(ctx context.Context, logFile string) *httplog.Logger
- func GetStartTime(ctx context.Context) time.Time
- func GetTraceID(ctx context.Context) string
- func GetTraceUserID(ctx context.Context) string
- func GetUserID(ctx context.Context) uuid.UUID
- func InitLogger(logFilePath string, name string) *httplog.Logger
- func InitLoggerBuffer(name string) (*httplog.Logger, *bytes.Buffer)
- func Time(next http.Handler) http.Handler
- func TraceID(next http.Handler) http.Handler
- func TraceUserID(next http.Handler) http.Handler
- type AuthInfo
- type AuthMethod
- type AuthMiddleware
Constants ¶
View Source
const ( TraceIDKey contextKeyTraceID = 0 UserIDKey contextKeyUserID = "user_id" )
Variables ¶
View Source
var ( AuthContextKey = &contextKey{"auth"} UserIDContextKey = &contextKey{"user"} )
View Source
var ( APILoggerKey = &contextKey{"logger"} RunLoggerKey = &contextKey{"runLogger"} RunLoggerBufferKey = &contextKey{"runLoggerBuffer"} )
View Source
var ( TraceIDHeader = "x-vision-trace" UserIDHeader = "x-vision-user" )
View Source
var StartTimeKey = &contextKey{"startTime"}
Functions ¶
func DefaultLoggerMiddleware ¶
func GetMiddlewareLogger ¶
func GetTraceID ¶
func GetTraceUserID ¶
func InitLogger ¶
func InitLoggerBuffer ¶
Types ¶
type AuthInfo ¶
type AuthInfo struct { AuthMethod AuthMethod StatusCode int }
func InitAuthInfo ¶
func InitAuthInfo() AuthInfo
type AuthMethod ¶
type AuthMethod string
const ( Basic AuthMethod = "BasicAuth" APIKey AuthMethod = "APIKeyAuth" )
type AuthMiddleware ¶
type AuthMiddleware struct {
// contains filtered or unexported fields
}
func NewAuthMiddleware ¶
func NewAuthMiddleware( userManager *user.UserManager, logFilePath string, ) *AuthMiddleware
func (*AuthMiddleware) BasicAuth ¶
func (m *AuthMiddleware) BasicAuth(next http.Handler) http.Handler
func (*AuthMiddleware) RequiredDev ¶
func (m *AuthMiddleware) RequiredDev() func(http.Handler) http.Handler
func (*AuthMiddleware) RequiredPE ¶
func (m *AuthMiddleware) RequiredPE() func(http.Handler) http.Handler
Click to show internal directories.
Click to hide internal directories.