authorizer/server/routes/routes.go

58 lines
2.0 KiB
Go
Raw Normal View History

2022-01-17 06:02:13 +00:00
package routes
import (
2022-05-12 19:17:01 +00:00
"github.com/gin-gonic/gin"
2022-05-25 09:34:26 +00:00
"github.com/sirupsen/logrus"
2022-05-12 19:17:01 +00:00
2022-01-17 06:02:13 +00:00
"github.com/authorizerdev/authorizer/server/handlers"
"github.com/authorizerdev/authorizer/server/middlewares"
)
// InitRouter initializes gin router
2022-05-25 09:34:26 +00:00
func InitRouter(log *logrus.Logger) *gin.Engine {
gin.SetMode(gin.ReleaseMode)
2022-05-25 07:00:22 +00:00
router := gin.New()
2022-05-25 09:34:26 +00:00
router.Use(middlewares.Logger(log), gin.Recovery())
2022-01-17 06:02:13 +00:00
router.Use(middlewares.GinContextToContextMiddleware())
router.Use(middlewares.CORSMiddleware())
router.GET("/", handlers.RootHandler())
2022-02-05 04:39:25 +00:00
router.GET("/health", handlers.HealthHandler())
2022-01-17 06:02:13 +00:00
router.POST("/graphql", handlers.GraphqlHandler())
router.GET("/playground", handlers.PlaygroundHandler())
router.GET("/oauth_login/:oauth_provider", handlers.OAuthLoginHandler())
router.GET("/oauth_callback/:oauth_provider", handlers.OAuthCallbackHandler())
router.POST("/oauth_callback/:oauth_provider", handlers.OAuthCallbackHandler())
2022-01-17 06:02:13 +00:00
router.GET("/verify_email", handlers.VerifyEmailHandler())
2022-02-23 05:54:52 +00:00
// OPEN ID routes
router.GET("/.well-known/openid-configuration", handlers.OpenIDConfigurationHandler())
router.GET("/.well-known/jwks.json", handlers.JWKsHandler())
2022-03-03 19:06:27 +00:00
router.GET("/authorize", handlers.AuthorizeHandler())
router.GET("/userinfo", handlers.UserInfoHandler())
router.GET("/logout", handlers.LogoutHandler())
2022-03-07 03:01:39 +00:00
router.POST("/oauth/token", handlers.TokenHandler())
router.POST("/oauth/revoke", handlers.RevokeRefreshTokenHandler())
2022-01-17 06:02:13 +00:00
router.LoadHTMLGlob("templates/*")
// login page app related routes.
2022-01-25 07:36:52 +00:00
app := router.Group("/app")
{
2022-01-31 06:05:24 +00:00
app.Static("/favicon_io", "app/favicon_io")
2022-01-25 07:36:52 +00:00
app.Static("/build", "app/build")
app.GET("/", handlers.AppHandler())
2022-01-31 06:05:24 +00:00
app.GET("/:page", handlers.AppHandler())
2022-01-17 06:02:13 +00:00
}
// dashboard related routes
2022-01-25 07:36:52 +00:00
dashboard := router.Group("/dashboard")
2022-01-17 06:02:13 +00:00
{
2022-01-31 06:05:24 +00:00
dashboard.Static("/favicon_io", "dashboard/favicon_io")
2022-01-25 07:36:52 +00:00
dashboard.Static("/build", "dashboard/build")
2022-03-16 18:45:47 +00:00
dashboard.Static("/public", "dashboard/public")
2022-01-25 07:36:52 +00:00
dashboard.GET("/", handlers.DashboardHandler())
dashboard.GET("/:page", handlers.DashboardHandler())
2022-01-17 06:02:13 +00:00
}
return router
}