96168dc6fb
- Updated API route structure to remove versioning and consolidate endpoints. - Refactored routing in `server.go` to use a unified `/api` prefix for all controllers. - Added new `ChannelController`, `ConversationController`, and `MessageController` to handle specific API functionalities. - Removed deprecated `OpenImContextMiddleware` and related logic. - Enhanced channel validation logic in `ChannelService` and `ChannelRepository`. - Updated frontend API calls to align with new endpoint structure.
22 lines
487 B
Go
22 lines
487 B
Go
package middleware
|
|
|
|
import (
|
|
"cs-agent/internal/pkg/irisx"
|
|
"cs-agent/internal/pkg/openidentity"
|
|
|
|
"github.com/kataras/iris/v12"
|
|
"github.com/mlogclub/simple/web"
|
|
)
|
|
|
|
// ChannelContextMiddleware 校验 X-Channel-Id / channelId 对应启用 web 渠道
|
|
func ChannelContextMiddleware(ctx iris.Context) {
|
|
ext, err := openidentity.GetExternalInfo(ctx)
|
|
if err != nil {
|
|
ctx.StopExecution()
|
|
_ = ctx.JSON(web.JsonError(err))
|
|
return
|
|
}
|
|
irisx.SetOpenImExternalInfo(ctx, ext)
|
|
ctx.Next()
|
|
}
|