From 0f6eaaa5c4265cff11d8ee0cab0564b046c22d2d Mon Sep 17 00:00:00 2001 From: Matt Hook Date: Wed, 13 Sep 2023 10:48:02 +1200 Subject: [PATCH] remove the payload --- http/handler/handler.go | 3 +++ http/handler/handlerv2.go | 5 ++++ .../kubernetes/kubernetes_namespaces.go | 23 +++++++++++-------- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/http/handler/handler.go b/http/handler/handler.go index ba07f44b..76724a2e 100644 --- a/http/handler/handler.go +++ b/http/handler/handler.go @@ -23,6 +23,7 @@ import ( "github.com/portainer/agent/http/proxy" "github.com/portainer/agent/http/security" kubecli "github.com/portainer/agent/kubernetes" + "github.com/rs/zerolog/log" ) // Handler is the main handler of the application. @@ -100,6 +101,8 @@ func (h *Handler) ServeHTTP(rw http.ResponseWriter, request *http.Request) { } rw.Header().Set(agent.HTTPResponseAgentPlatform, strconv.Itoa(int(agentPlatformIdentifier))) + log.Debug().Msgf("Handling request: %s %s", request.Method, request.URL.Path) + switch { case strings.HasPrefix(request.URL.Path, "/v1"): h.ServeHTTPV1(rw, request) diff --git a/http/handler/handlerv2.go b/http/handler/handlerv2.go index 52f2a535..c4c284af 100644 --- a/http/handler/handlerv2.go +++ b/http/handler/handlerv2.go @@ -3,10 +3,15 @@ package handler import ( "net/http" "strings" + + "github.com/rs/zerolog/log" ) // ServeHTTPV2 is the HTTP router for all v2 api requests. func (h *Handler) ServeHTTPV2(rw http.ResponseWriter, request *http.Request) { + + log.Debug().Msgf("Request: %s %s", request.Method, request.URL.Path) + switch { case strings.HasPrefix(request.URL.Path, "/v2/ping"): http.StripPrefix("/v2", h.pingHandler).ServeHTTP(rw, request) diff --git a/http/handler/kubernetes/kubernetes_namespaces.go b/http/handler/kubernetes/kubernetes_namespaces.go index a2175a95..af08a624 100644 --- a/http/handler/kubernetes/kubernetes_namespaces.go +++ b/http/handler/kubernetes/kubernetes_namespaces.go @@ -5,23 +5,26 @@ import ( "net/http" httperror "github.com/portainer/portainer/pkg/libhttp/error" - "github.com/portainer/portainer/pkg/libhttp/request" "github.com/portainer/portainer/pkg/libhttp/response" + "github.com/rs/zerolog/log" ) -type getNamespacePayload struct{} +// type getNamespacePayload struct{} -func (payload *getNamespacePayload) Validate(r *http.Request) error { +// func (payload *getNamespacePayload) Validate(r *http.Request) error { - return nil -} +// return nil +// } func (handler *Handler) kubernetesGetNamespaces(rw http.ResponseWriter, r *http.Request) *httperror.HandlerError { - var payload getNamespacePayload - err := request.DecodeAndValidateJSONPayload(r, &payload) - if err != nil { - return httperror.BadRequest("Invalid request payload", err) - } + + log.Debug().Msgf("GetNamespaces Handler: Request: %s %s", r.Method, r.URL.Path) + + // var payload getNamespacePayload + // err := request.DecodeAndValidateJSONPayload(r, &payload) + // if err != nil { + // return httperror.BadRequest("Invalid request payload", err) + // } for _, header := range r.Header { for _, value := range header {