middleware

package
v0.1.0-alpha.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 4, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

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 APILoggerMiddleware

func APILoggerMiddleware(logFile string) func(http.Handler) http.Handler

func DefaultLoggerMiddleware

func DefaultLoggerMiddleware(logFile string) func(http.Handler) http.Handler

func GetMiddlewareLogger

func GetMiddlewareLogger(ctx context.Context, logFile string) *httplog.Logger

func GetStartTime

func GetStartTime(ctx context.Context) time.Time

func GetTraceID

func GetTraceID(ctx context.Context) string

func GetTraceUserID

func GetTraceUserID(ctx context.Context) string

func GetUserID

func GetUserID(ctx context.Context) uuid.UUID

func InitLogger

func InitLogger(logFilePath string, name string) *httplog.Logger

func InitLoggerBuffer

func InitLoggerBuffer(name string) (*httplog.Logger, *bytes.Buffer)

func Time

func Time(next http.Handler) http.Handler

func TraceID

func TraceID(next http.Handler) http.Handler

func TraceUserID

func TraceUserID(next http.Handler) http.Handler

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL