2023-12-17 13:16:15 +08:00
|
|
|
package httpd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/opentdp/go-helper/httpd"
|
|
|
|
|
2023-12-18 08:48:14 +08:00
|
|
|
"wechat-rest/args"
|
|
|
|
"wechat-rest/httpd/midware"
|
|
|
|
"wechat-rest/httpd/wcfrest"
|
2023-12-17 13:16:15 +08:00
|
|
|
)
|
|
|
|
|
2024-01-12 09:02:19 +08:00
|
|
|
// @title WeChat Rest Api
|
2024-01-19 12:04:34 +08:00
|
|
|
// @version v0.10.0
|
2024-01-12 09:02:19 +08:00
|
|
|
// @description 基于 WeChatFerry RPC 实现的微信接口,使用 Go 语言编写,无第三方运行时依赖,易于对接任意编程语言。
|
2023-12-17 13:16:15 +08:00
|
|
|
// @contact.name WeChatRest
|
|
|
|
// @contact.url https://github.com/opentdp/wechat-rest
|
|
|
|
// @license.name Apache 2.0
|
|
|
|
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
|
|
|
|
// @BasePath /api
|
|
|
|
|
|
|
|
func Server() {
|
|
|
|
|
|
|
|
httpd.Engine(args.Debug)
|
|
|
|
|
2023-12-29 21:28:18 +08:00
|
|
|
// Api 守卫
|
2023-12-17 13:16:15 +08:00
|
|
|
api := httpd.Group("/api")
|
2024-01-10 09:59:47 +08:00
|
|
|
api.Use(midware.OutputHandle, midware.ApiGuard)
|
2023-12-17 13:16:15 +08:00
|
|
|
|
2023-12-29 21:28:18 +08:00
|
|
|
// Wcf 路由
|
2023-12-17 13:16:15 +08:00
|
|
|
wcfrest.Route(api)
|
|
|
|
|
2023-12-29 21:28:18 +08:00
|
|
|
// Swagger 守卫
|
2024-01-19 12:04:34 +08:00
|
|
|
httpd.Use(midware.SwaggerGuard)
|
2023-12-29 21:28:18 +08:00
|
|
|
|
2023-12-17 13:16:15 +08:00
|
|
|
// 前端文件路由
|
|
|
|
httpd.StaticEmbed("/", "public", args.Efs)
|
|
|
|
|
|
|
|
// 启动 HTTP 服务
|
2024-01-19 12:04:34 +08:00
|
|
|
httpd.Server(args.Web.Address)
|
2023-12-17 13:16:15 +08:00
|
|
|
|
|
|
|
}
|