2022-01-17 06:02:13 +00:00
|
|
|
package routes
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/authorizerdev/authorizer/server/handlers"
|
|
|
|
"github.com/authorizerdev/authorizer/server/middlewares"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
)
|
|
|
|
|
|
|
|
// InitRouter initializes gin router
|
|
|
|
func InitRouter() *gin.Engine {
|
|
|
|
router := gin.Default()
|
2022-01-31 06:05:24 +00:00
|
|
|
// router.Use(location.Default())
|
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.GET("/verify_email", handlers.VerifyEmailHandler())
|
2022-02-23 05:54:52 +00:00
|
|
|
// OPEN ID routes
|
|
|
|
router.GET("/.well-known/openid-configuration", handlers.OpenIDConfigurationHandler())
|
2022-02-26 12:44:43 +00:00
|
|
|
router.GET("/.well-known/jwks.json", handlers.JWKsHandler())
|
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")
|
|
|
|
dashboard.GET("/", handlers.DashboardHandler())
|
|
|
|
dashboard.GET("/:page", handlers.DashboardHandler())
|
2022-01-17 06:02:13 +00:00
|
|
|
}
|
|
|
|
return router
|
|
|
|
}
|