Files
xiaohongshu-mcp/routes.go
zy aa09687751 feat: 添加搜索功能 (#16)
- 新增 SearchFeeds 服务方法,支持关键词搜索小红书内容
- 添加 search_feeds MCP 工具,提供搜索接口
- 新增 /api/v1/feeds/search API 端点
- 实现搜索页面的浏览器自动化操作
- 优化 MCP 协议支持,处理 notifications/initialized 和 notifications/cancelled 通知
- 更新文档,添加搜索功能说明和使用示例
- 重构类型定义,优化数据结构

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Claude <noreply@anthropic.com>
2025-08-17 23:35:22 +08:00

39 lines
883 B
Go

package main
import (
"github.com/gin-gonic/gin"
)
// setupRoutes 设置路由配置
func setupRoutes(appServer *AppServer) *gin.Engine {
// 设置 Gin 模式
gin.SetMode(gin.ReleaseMode)
router := gin.New()
router.Use(gin.Logger())
router.Use(gin.Recovery())
// 添加中间件
router.Use(errorHandlingMiddleware())
router.Use(corsMiddleware())
// 健康检查
router.GET("/health", healthHandler)
// MCP 端点 - 使用 SSE 协议
mcpHandler := appServer.createMCPHandler()
router.Any("/mcp", gin.WrapH(mcpHandler))
router.Any("/mcp/*path", gin.WrapH(mcpHandler))
// API 路由组
api := router.Group("/api/v1")
{
api.GET("/login/status", appServer.checkLoginStatusHandler)
api.POST("/publish", appServer.publishHandler)
api.GET("/feeds/list", appServer.listFeedsHandler)
api.GET("/feeds/search", appServer.searchFeedsHandler)
}
return router
}