Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Commit

Permalink
remove unused interface
Browse files Browse the repository at this point in the history
  • Loading branch information
gossion committed Jan 8, 2021
1 parent 7930436 commit 578dd8c
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions internal/commands/root/mux.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ import (
"k8s.io/apiserver/pkg/authorization/authorizer"
)

// ServeMux contains the methods required to implement a mux that can be wrapped with auth filter
type ServeMux interface {
Handle(path string, h http.Handler)
ServeHTTP(w http.ResponseWriter, r *http.Request)
}

// ServeMuxWithAuth implements api.ServerMux
type ServeMuxWithAuth struct {
auth AuthInterface
Expand All @@ -37,25 +31,25 @@ type ServeMuxWithAuth struct {
}

// NewServeMuxWithAuth initiate an instance for ServeMuxWithAuth
func NewServeMuxWithAuth(ctx context.Context, auth AuthInterface) ServeMux {
func NewServeMuxWithAuth(ctx context.Context, auth AuthInterface) *ServeMuxWithAuth {
mux := http.NewServeMux()
return ServeMuxWithAuth{
return &ServeMuxWithAuth{
auth: auth,
ctx: ctx,
mux: mux,
}
}

// Handle enables auth filter for mux Handle
func (s ServeMuxWithAuth) Handle(path string, h http.Handler) {
func (s *ServeMuxWithAuth) Handle(path string, h http.Handler) {
if s.auth == nil {
s.mux.Handle(path, h)
} else {
s.mux.Handle(path, s.authHandler(h))
}
}

func (s ServeMuxWithAuth) ServeHTTP(w http.ResponseWriter, r *http.Request) {
func (s *ServeMuxWithAuth) ServeHTTP(w http.ResponseWriter, r *http.Request) {
s.mux.ServeHTTP(w, r)
}

Expand Down

0 comments on commit 578dd8c

Please sign in to comment.