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