indiescrobble/server/router.go

47 lines
940 B
Go
Raw Normal View History

package server
import (
"git.jamesravey.me/ravenscroftj/indiescrobble/config"
"git.jamesravey.me/ravenscroftj/indiescrobble/controllers"
"git.jamesravey.me/ravenscroftj/indiescrobble/middlewares"
"github.com/gin-gonic/gin"
)
func NewRouter() *gin.Engine {
router := gin.New()
router.Use(gin.Logger())
router.Use(gin.Recovery())
config := config.GetConfig()
health := new(controllers.HealthController)
2022-02-05 16:24:07 +00:00
iam := controllers.NewIndieAuthManager()
router.GET("/health", health.Status)
2022-02-05 16:24:07 +00:00
router.Use(middlewares.AuthMiddleware())
router.GET("/", controllers.Index)
router.Static("/static", config.GetString("server.static_path"))
2022-02-05 16:24:07 +00:00
router.POST("/indieauth", iam.IndieAuthLoginPost)
router.GET("/auth", iam.LoginCallbackGet)
// v1 := router.Group("v1")
// {
// userGroup := v1.Group("user")
// {
// user := new(controllers.UserController)
// userGroup.GET("/:id", user.Retrieve)
// }
// }
return router
}