Files
ai-agent/internal/middleware/open_im_middleware.go
T
mlogclub 96168dc6fb Refactor API routes and controllers for improved structure and clarity
- 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.
2026-04-25 10:27:43 +08:00

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()
}