Skip to content

Commit

Permalink
checkpoint
Browse files Browse the repository at this point in the history
Signed-off-by: Jeff Ortel <[email protected]>
  • Loading branch information
jortel committed Sep 10, 2024
1 parent 21d4c42 commit 928a2a5
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions api/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type ServiceHandler struct {
// AddRoutes adds routes.
func (h ServiceHandler) AddRoutes(e *gin.Engine) {
e.GET(ServicesRoot, h.List)
e.Any(ServiceRoot, h.Forward)
e.Any(ServiceRoot, h.Required, h.Forward)
}

// List godoc
Expand All @@ -49,14 +49,15 @@ func (h ServiceHandler) List(ctx *gin.Context) {
h.Respond(ctx, http.StatusOK, r)
}

// Required enforces RBAC.
func (h ServiceHandler) Required(ctx *gin.Context) {
Required(ctx.Param(Name))
}

// Forward provides RBAC and forwards request to the service.
func (h ServiceHandler) Forward(ctx *gin.Context) {
path := ctx.Param(Wildcard)
name := ctx.Param(Name)
Required(name)
if len(ctx.Errors) > 0 {
return
}
route, found := serviceRoutes[name]
if !found {
err := &NotFound{Resource: name}
Expand Down

0 comments on commit 928a2a5

Please sign in to comment.