Skip to content

Commit

Permalink
remove the payload
Browse files Browse the repository at this point in the history
  • Loading branch information
hookenz committed Sep 12, 2023
1 parent bef452f commit 0f6eaaa
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
3 changes: 3 additions & 0 deletions http/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions http/handler/handlerv2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
23 changes: 13 additions & 10 deletions http/handler/kubernetes/kubernetes_namespaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 0f6eaaa

Please sign in to comment.