Skip to content

Commit

Permalink
Fix path
Browse files Browse the repository at this point in the history
  • Loading branch information
olevitt committed Mar 21, 2024
1 parent 31e204b commit dfa37ab
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 10 deletions.
7 changes: 5 additions & 2 deletions cmd/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ package cmd

import "github.com/gin-gonic/gin"

func RegisterHandlers(r *gin.Engine) {
func RegisterPublicHandlers(r *gin.RouterGroup) {
registerPublicHandlers(r)
}

func RegisterPrivateHandlers(r *gin.RouterGroup) {
registerUserHandlers(r)
registerMyLabHandlers(r)
registerPublicHandlers(r)
}
2 changes: 1 addition & 1 deletion cmd/mylab-handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func quotas(c *gin.Context) {
}*/
}

func registerMyLabHandlers(r *gin.Engine) {
func registerMyLabHandlers(r *gin.RouterGroup) {
r.GET("/my-lab/services", myServices)
r.GET("/my-lab/events", events)
r.GET("/my-lab/quota", quotas)
Expand Down
9 changes: 7 additions & 2 deletions cmd/public-handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ func ip(c *gin.Context) {
})
}

func registerPublicHandlers(r *gin.Engine) {
r.GET("/public/ip", ip)
func healthcheck(c *gin.Context) {
c.Status(http.StatusOK)
}

func registerPublicHandlers(r *gin.RouterGroup) {
r.GET("/ip", ip)
r.GET("/healthcheck", healthcheck)
}
2 changes: 1 addition & 1 deletion cmd/user-handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ func userInfo(c *gin.Context) {
c.JSON(http.StatusOK, userInfo)
}

func registerUserHandlers(r *gin.Engine) {
func registerUserHandlers(r *gin.RouterGroup) {
r.GET("/user/info", userInfo)
}
3 changes: 2 additions & 1 deletion config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
authentication:
issuerURI:
audience:
audience:
rootPath: /api
1 change: 1 addition & 0 deletions configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

type configuration struct {
Authentication authentication
RootPath string
}

type authentication struct {
Expand Down
10 changes: 7 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ import (
func main() {
loadConfiguration()
r := gin.Default()
r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerfiles.Handler))
baseRoutes := r.Group(config.RootPath)
baseRoutes.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerfiles.Handler))
privateRoutes := baseRoutes.Group("/")
publicRoutes := baseRoutes.Group("/public")

zap.ReplaceGlobals(zap.Must(zap.NewProduction()))

Expand All @@ -42,11 +45,12 @@ func main() {
oidcConfig.SkipClientIDCheck = true
}
verifier := provider.Verifier(oidcConfig)
r.Use(cmd.AuthMiddleware(ctx, verifier))
privateRoutes.Use(cmd.AuthMiddleware(ctx, verifier))
}

kubernetes.InitClient()

cmd.RegisterHandlers(r)
cmd.RegisterPrivateHandlers(privateRoutes)
cmd.RegisterPublicHandlers(publicRoutes)
r.Run()
}

0 comments on commit dfa37ab

Please sign in to comment.