From 384685327fd036772b12c426bb0cee84f0c3d4f6 Mon Sep 17 00:00:00 2001 From: mike76-dev Date: Fri, 26 Apr 2024 15:59:21 +0200 Subject: [PATCH] Remove unused code --- modules/portal/auth.go | 10 +++++----- modules/portal/dashboard.go | 6 +++--- modules/portal/google.go | 2 +- modules/portal/network.go | 6 +++--- modules/portal/stripe.go | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/modules/portal/auth.go b/modules/portal/auth.go index 13ca411..d7cb398 100644 --- a/modules/portal/auth.go +++ b/modules/portal/auth.go @@ -98,7 +98,7 @@ func (api *portalAPI) loginHandlerPOST(w http.ResponseWriter, req *http.Request, var data struct { Email string `json:"email"` } - err, code := api.handleDecodeError(w, dec.Decode(&data)) + err, code := api.handleDecodeError(dec.Decode(&data)) if code != http.StatusOK { writeError(w, err, code) return @@ -203,7 +203,7 @@ func (api *portalAPI) registerHandlerPOST(w http.ResponseWriter, req *http.Reque var data struct { Email string `json:"email"` } - err, code := api.handleDecodeError(w, dec.Decode(&data)) + err, code := api.handleDecodeError(dec.Decode(&data)) if code != http.StatusOK { writeError(w, err, code) return @@ -434,7 +434,7 @@ func (api *portalAPI) registerResendHandlerPOST(w http.ResponseWriter, req *http var data struct { Email string `json:"email"` } - err, code := api.handleDecodeError(w, dec.Decode(&data)) + err, code := api.handleDecodeError(dec.Decode(&data)) if code != http.StatusOK { writeError(w, err, code) return @@ -580,7 +580,7 @@ func (api *portalAPI) resetHandlerPOST(w http.ResponseWriter, req *http.Request, var data struct { Email string `json:"email"` } - err, code := api.handleDecodeError(w, dec.Decode(&data)) + err, code := api.handleDecodeError(dec.Decode(&data)) if code != http.StatusOK { writeError(w, err, code) return @@ -634,7 +634,7 @@ func (api *portalAPI) resetResendHandlerPOST(w http.ResponseWriter, req *http.Re var data struct { Email string `json:"email"` } - err, code := api.handleDecodeError(w, dec.Decode(&data)) + err, code := api.handleDecodeError(dec.Decode(&data)) if code != http.StatusOK { writeError(w, err, code) return diff --git a/modules/portal/dashboard.go b/modules/portal/dashboard.go index 301b6cc..ea27322 100644 --- a/modules/portal/dashboard.go +++ b/modules/portal/dashboard.go @@ -214,7 +214,7 @@ func (api *portalAPI) hostsHandlerPOST(w http.ResponseWriter, req *http.Request, } var data hostsRequest - hdErr, code := api.handleDecodeError(w, dec.Decode(&data)) + hdErr, code := api.handleDecodeError(dec.Decode(&data)) if code != http.StatusOK { writeError(w, hdErr, code) return @@ -759,7 +759,7 @@ func (api *portalAPI) filesHandlerPOST(w http.ResponseWriter, req *http.Request, } var data fileDeleteRequest - hdErr, code := api.handleDecodeError(w, dec.Decode(&data)) + hdErr, code := api.handleDecodeError(dec.Decode(&data)) if code != http.StatusOK { writeError(w, hdErr, code) return @@ -813,7 +813,7 @@ func (api *portalAPI) settingsHandlerPOST(w http.ResponseWriter, req *http.Reque } var settings modules.RenterSettings - hdErr, code := api.handleDecodeError(w, dec.Decode(&settings)) + hdErr, code := api.handleDecodeError(dec.Decode(&settings)) if code != http.StatusOK { writeError(w, hdErr, code) return diff --git a/modules/portal/google.go b/modules/portal/google.go index 3b2d376..c81ec17 100644 --- a/modules/portal/google.go +++ b/modules/portal/google.go @@ -47,7 +47,7 @@ func (api *portalAPI) authHandlerPOST(w http.ResponseWriter, req *http.Request, } var data googleAuth - gErr, code := api.handleDecodeError(w, dec.Decode(&data)) + gErr, code := api.handleDecodeError(dec.Decode(&data)) if code != http.StatusOK { writeError(w, gErr, code) return diff --git a/modules/portal/network.go b/modules/portal/network.go index aaa6cbf..92e67ac 100644 --- a/modules/portal/network.go +++ b/modules/portal/network.go @@ -244,7 +244,7 @@ func (err Error) Error() string { } // checkHeader checks the HTTP request header for the right content type. -func checkHeader(w http.ResponseWriter, r *http.Request) Error { +func checkHeader(r *http.Request) Error { value := r.Header.Get("Content-Type") if value != "" && !strings.Contains(value, "application/json") { return Error{ @@ -259,7 +259,7 @@ func checkHeader(w http.ResponseWriter, r *http.Request) Error { // json.Decoder. func prepareDecoder(w http.ResponseWriter, r *http.Request) (*json.Decoder, error) { // Check the response header first. - if err := checkHeader(w, r); err.Code != httpErrorNone { + if err := checkHeader(r); err.Code != httpErrorNone { writeError(w, err, http.StatusUnsupportedMediaType) return nil, errors.New(err.Message) } @@ -278,7 +278,7 @@ func prepareDecoder(w http.ResponseWriter, r *http.Request) (*json.Decoder, erro // handleDecodeError parses the json.Decoder errors and returns an // error message and a response code. -func (api *portalAPI) handleDecodeError(w http.ResponseWriter, err error) (Error, int) { +func (api *portalAPI) handleDecodeError(err error) (Error, int) { if err == nil { return Error{}, http.StatusOK } diff --git a/modules/portal/stripe.go b/modules/portal/stripe.go index 105c665..5e2af5d 100644 --- a/modules/portal/stripe.go +++ b/modules/portal/stripe.go @@ -183,7 +183,7 @@ func (api *portalAPI) paymentHandlerPOST(w http.ResponseWriter, req *http.Reques var data struct { Items []item `json:"items"` } - err, code := api.handleDecodeError(w, dec.Decode(&data)) + err, code := api.handleDecodeError(dec.Decode(&data)) if code != http.StatusOK { writeError(w, err, code) return