mirror of
https://github.com/twofas/2fas-server.git
synced 2024-12-12 04:00:15 +01:00
23 lines
342 B
Go
23 lines
342 B
Go
package http
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func RunHttpServer(addr string, init func(engine *gin.Engine)) {
|
|
router := gin.New()
|
|
|
|
router.Use(gin.Recovery())
|
|
router.Use(corsMiddleware())
|
|
router.Use(LoggingMiddleware())
|
|
router.Use(RequestJsonLogger())
|
|
|
|
init(router)
|
|
|
|
err := router.Run(addr)
|
|
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}
|