Refactor import paths to use internal/pkg/httpx/params
- Updated multiple repository and service files to replace imports from "github.com/mlogclub/simple/web/params" with "cs-agent/internal/pkg/httpx/params". - Adjusted context handling in auth_service and ws_service to use gin.Context instead of iris.Context. - Ensured consistent usage of HTTP status responses across websocket handlers.
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package httpx
|
||||
|
||||
import (
|
||||
"cs-agent/internal/pkg/httpx/params"
|
||||
"cs-agent/internal/pkg/openidentity"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/mlogclub/simple/common/strs"
|
||||
)
|
||||
|
||||
const (
|
||||
ctxKeyExternalUser = "externalUser"
|
||||
)
|
||||
|
||||
func SetExternalUser(ctx *gin.Context, ext *openidentity.ExternalUser) {
|
||||
ctx.Set(ctxKeyExternalUser, ext)
|
||||
}
|
||||
|
||||
func GetExternalUser(ctx *gin.Context) *openidentity.ExternalUser {
|
||||
v, _ := ctx.Get(ctxKeyExternalUser)
|
||||
ext, _ := v.(*openidentity.ExternalUser)
|
||||
return ext
|
||||
}
|
||||
|
||||
func GetChannelID(ctx *gin.Context) string {
|
||||
if channelID := ctx.GetHeader("X-Channel-ID"); strs.IsNotBlank(channelID) {
|
||||
return channelID
|
||||
}
|
||||
if channelID, _ := params.Get(ctx, "channelId"); strs.IsNotBlank(channelID) {
|
||||
return channelID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
Reference in New Issue
Block a user