Skip to content

Commit

Permalink
add PublicViewer's middleware
Browse files Browse the repository at this point in the history
this commit is part of the effort of splitting #443

Signed-off-by: Francesco Ilario <filario@redhat.com>
  • Loading branch information
filariow committed Aug 26, 2024
1 parent 2b62f6c commit 3ccbee7
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ func (p *Proxy) StartProxy(port string) *http.Server {
return next(ctx)
}
},
p.addPublicViewerContext(),
)

// middleware after routing
Expand Down Expand Up @@ -568,6 +569,17 @@ func (p *Proxy) addUserContext() echo.MiddlewareFunc {
}
}

// addPublicViewerContext updates echo.Context with the configuration's PublicViewerEnabled value.
func (p *Proxy) addPublicViewerContext() echo.MiddlewareFunc {
return func(next echo.HandlerFunc) echo.HandlerFunc {
return func(ctx echo.Context) error {
publicViewerEnabled := configuration.GetRegistrationServiceConfig().PublicViewerEnabled()
ctx.Set(context.PublicViewerEnabled, publicViewerEnabled)
return next(ctx)
}
}
}

func (p *Proxy) stripInvalidHeaders() echo.MiddlewareFunc {
return func(next echo.HandlerFunc) echo.HandlerFunc {
return func(ctx echo.Context) error {
Expand Down

0 comments on commit 3ccbee7

Please sign in to comment.