feat: 添加 webserver 包并重构主函数以启动路由
- 新增 webserver/router.go 文件,定义了 Gin 服务器和相关路由 - 在 main.go 中调用 webserver.StartRouter() 启动路由
This commit is contained in:
parent
7f1fda11b0
commit
9d512fd4e3
3
main.go
3
main.go
@ -11,6 +11,7 @@ import (
|
||||
"git.lxtend.com/qqbot/config"
|
||||
"git.lxtend.com/qqbot/service/exec"
|
||||
"git.lxtend.com/qqbot/sqlite3"
|
||||
"git.lxtend.com/qqbot/webserver"
|
||||
_ "git.lxtend.com/qqbot/works"
|
||||
wsclient "git.lxtend.com/qqbot/ws_client"
|
||||
"github.com/gin-gonic/gin"
|
||||
@ -65,7 +66,7 @@ func main() {
|
||||
time.Sleep(reconnectDelay)
|
||||
}
|
||||
}()
|
||||
startRouter()
|
||||
webserver.StartRouter()
|
||||
for {
|
||||
time.Sleep(1000 * time.Second)
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package main
|
||||
package webserver
|
||||
|
||||
import (
|
||||
"time"
|
||||
@ -10,7 +10,7 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func startRouter() {
|
||||
func StartRouter() {
|
||||
ginServer := gin.New()
|
||||
ginServer.Use(cors.New(cors.Config{
|
||||
AllowOrigins: []string{"https://www.lxtend.com", "https://git.lxtend.com"},
|
Loading…
x
Reference in New Issue
Block a user