mirror of
https://github.com/h44z/wg-portal.git
synced 2025-09-15 07:11:15 +00:00
chore: replace gin with standard lib net/http
This commit is contained in:
@@ -4,8 +4,6 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
const CtxUserInfo = "userInfo"
|
||||
@@ -47,21 +45,6 @@ func SystemAdminContextUserInfo() *ContextUserInfo {
|
||||
}
|
||||
}
|
||||
|
||||
// SetUserInfoFromGin sets the user info from the gin context to the request context.
|
||||
func SetUserInfoFromGin(c *gin.Context) context.Context {
|
||||
ginUserInfo, exists := c.Get(CtxUserInfo)
|
||||
|
||||
info := DefaultContextUserInfo()
|
||||
if exists {
|
||||
if ginInfo, ok := ginUserInfo.(*ContextUserInfo); ok {
|
||||
info = ginInfo
|
||||
}
|
||||
}
|
||||
|
||||
ctx := SetUserInfo(c.Request.Context(), info)
|
||||
return ctx
|
||||
}
|
||||
|
||||
// SetUserInfo sets the user info in the context.
|
||||
func SetUserInfo(ctx context.Context, info *ContextUserInfo) context.Context {
|
||||
ctx = context.WithValue(ctx, CtxUserInfo, info)
|
||||
|
Reference in New Issue
Block a user