Skip to content

Commit

Permalink
Remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
mike76-dev committed Apr 26, 2024
1 parent 332d6a7 commit 3846853
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
10 changes: 5 additions & 5 deletions modules/portal/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions modules/portal/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion modules/portal/google.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions modules/portal/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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)
}
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion modules/portal/stripe.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3846853

Please sign in to comment.