refactor: inline ready handler

This commit is contained in:
mrjoelkamp
2024-07-25 09:27:18 -05:00
parent efaca26eda
commit 44a8819a5b
2 changed files with 3 additions and 23 deletions

10
main.go
View File

@@ -101,15 +101,11 @@ func main() {
os.Exit(1)
}
readyHandler, err := handler.NewReadyHandler()
if err != nil {
klog.ErrorS(err, "unable to create ready handler")
os.Exit(1)
}
mux.Handle("POST /validate", http.TimeoutHandler(validateHandler, handlerTimeout, timeoutError))
mux.Handle("POST /mutate", http.TimeoutHandler(mutateHandler, handlerTimeout, timeoutError))
mux.Handle("GET /ready", readyHandler)
mux.Handle("GET /ready", http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusOK)
}))
server := &http.Server{
Addr: fmt.Sprintf(":%d", port),

View File

@@ -1,16 +0,0 @@
package handler
import (
"net/http"
)
type readyHandler struct{}
// NewReadyHandler returns a readiness probe handler.
func NewReadyHandler() (http.Handler, error) {
return &readyHandler{}, nil
}
func (h *readyHandler) ServeHTTP(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusOK)
}