Skip to content

Commit

Permalink
Merge pull request #1391 from facchettos/extra-handlers
Browse files Browse the repository at this point in the history
added the possibility to run handlers before the filters
  • Loading branch information
FabianKramm authored Dec 4, 2023
2 parents 950228e + 3727aad commit 4e512e2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,10 @@ func NewServer(ctx *options.ControllerContext, requestHeaderCaFile, clientCaFile
})
}

for _, handler := range ctx.ExtraHandlers {
h = handler(h)
}

serverhelper.HandleRoute(s.handler, "/", h)

return s, nil
Expand Down
4 changes: 4 additions & 0 deletions pkg/setup/options/controller_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package options

import (
"context"
"net/http"

servertypes "github.com/loft-sh/vcluster/pkg/server/types"
"k8s.io/apimachinery/pkg/util/sets"
Expand All @@ -26,4 +27,7 @@ type ControllerContext struct {
AdditionalServerFilters []servertypes.Filter
Options *VirtualClusterOptions
StopChan <-chan struct{}

//set of extra services that should handle the traffic or pass it along
ExtraHandlers []func(http.Handler) http.Handler
}

0 comments on commit 4e512e2

Please sign in to comment.