Files
traefik-github-oauth-plugin/internal/app/traefik-github-oauth-server/router/router.go
MuXiu1997 8dcde8383f chore: fix module name
closed #12
2023-01-26 21:49:21 +08:00

33 lines
900 B
Go

package router
import (
"net/http"
server "github.com/MuXiu1997/traefik-github-oauth-plugin/internal/app/traefik-github-oauth-server"
"github.com/MuXiu1997/traefik-github-oauth-plugin/internal/pkg/constant"
"github.com/gin-gonic/gin"
)
func RegisterRoutes(app *server.App) {
apiSecretKeyMiddleware := server.NewApiSecretKeyMiddleware(app.Config.ApiSecretKey)
app.Engine.GET("/", func(c *gin.Context) {
c.String(http.StatusOK, "Traefik GitHub OAuth Server")
})
app.Engine.GET(constant.ROUTER_PATH_OAUTH_HEALTH, healthCheck(app))
oauthGroup := app.Engine.Group(constant.ROUTER_GROUP_PATH_OAUTH)
oauthGroup.POST(
constant.ROUTER_PATH_OAUTH_PAGE_URL,
apiSecretKeyMiddleware,
generateOAuthPageURL(app),
)
oauthGroup.GET(constant.ROUTER_PATH_OAUTH_REDIRECT, redirect(app))
oauthGroup.GET(
constant.ROUTER_PATH_OAUTH_RESULT,
apiSecretKeyMiddleware,
getAuthResult(app),
)
}