Skip to content

Commit

Permalink
added the possibility to run handlers before the filters
Browse files Browse the repository at this point in the history
  • Loading branch information
facchettos committed Dec 4, 2023
1 parent 094e41e commit 3727aad
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 3727aad

Please sign in to comment.