qq_bot/router.go
2024-10-26 03:30:54 +08:00

28 lines
815 B
Go

package main
import (
"time"
"git.lxtend.com/qqbot/handler/ticket"
"git.lxtend.com/qqbot/health"
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
)
func startRouter() {
ginServer := gin.New()
ginServer.Use(cors.New(cors.Config{
AllowOrigins: []string{"https://www.lxtend.com"},
AllowMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
AllowHeaders: []string{"Origin", "Content-Type", "Accept", "Authorization", "X-CSRF-Token"},
ExposeHeaders: []string{"Content-Length", "X-CSRF-Token"},
AllowCredentials: true,
MaxAge: 12 * time.Hour,
}))
healthEngine := ginServer.Group("/health")
healthEngine.GET("/ping", health.HealthHandler)
ticketEngine := ginServer.Group("/ticket")
ticketEngine.GET("", ticket.TicketHandler)
go ginServer.Run(":3434")
}