chore: linter: usestdlibvars
Signed-off-by: Jakob Borg <jakob@kastelo.net>
This commit is contained in:
@@ -118,7 +118,7 @@ func handleFailureFn(dsn, failureDir string, ignore *ignorePatterns) func(w http
|
|||||||
bs, err := io.ReadAll(lr)
|
bs, err := io.ReadAll(lr)
|
||||||
req.Body.Close()
|
req.Body.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), 500)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,7 +130,7 @@ func handleFailureFn(dsn, failureDir string, ignore *ignorePatterns) func(w http
|
|||||||
var reports []ur.FailureReport
|
var reports []ur.FailureReport
|
||||||
err = json.Unmarshal(bs, &reports)
|
err = json.Unmarshal(bs, &reports)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), 400)
|
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if len(reports) == 0 {
|
if len(reports) == 0 {
|
||||||
@@ -141,7 +141,7 @@ func handleFailureFn(dsn, failureDir string, ignore *ignorePatterns) func(w http
|
|||||||
|
|
||||||
version, err := build.ParseVersion(reports[0].Version)
|
version, err := build.ParseVersion(reports[0].Version)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), 400)
|
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, r := range reports {
|
for _, r := range reports {
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
"github.com/AudriusButkevicius/recli"
|
"github.com/AudriusButkevicius/recli"
|
||||||
@@ -86,7 +87,7 @@ func (h *configHandler) configAfter(_ *cli.Context) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if resp.StatusCode != 200 {
|
if resp.StatusCode != http.StatusOK {
|
||||||
body, err := responseToBArray(resp)
|
body, err := responseToBArray(resp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ package cli
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/alecthomas/kong"
|
"github.com/alecthomas/kong"
|
||||||
@@ -34,7 +35,7 @@ func (e *errorsPushCommand) Run(ctx Context) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if response.StatusCode != 200 {
|
if response.StatusCode != http.StatusOK {
|
||||||
errStr = fmt.Sprint("Failed to push error\nStatus code: ", response.StatusCode)
|
errStr = fmt.Sprint("Failed to push error\nStatus code: ", response.StatusCode)
|
||||||
bytes, err := responseToBArray(response)
|
bytes, err := responseToBArray(response)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/alecthomas/kong"
|
"github.com/alecthomas/kong"
|
||||||
@@ -63,7 +64,7 @@ func (f *folderOverrideCommand) Run(ctx Context) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if response.StatusCode != 200 {
|
if response.StatusCode != http.StatusOK {
|
||||||
errStr := fmt.Sprint("Failed to override changes\nStatus code: ", response.StatusCode)
|
errStr := fmt.Sprint("Failed to override changes\nStatus code: ", response.StatusCode)
|
||||||
bytes, err := responseToBArray(response)
|
bytes, err := responseToBArray(response)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -388,8 +388,8 @@ func upgradeViaRest() error {
|
|||||||
}
|
}
|
||||||
u.Path = path.Join(u.Path, "rest/system/upgrade")
|
u.Path = path.Join(u.Path, "rest/system/upgrade")
|
||||||
target := u.String()
|
target := u.String()
|
||||||
r, _ := http.NewRequest("POST", target, nil)
|
r, _ := http.NewRequest(http.MethodPost, target, nil)
|
||||||
r.Header.Set("X-API-Key", cfg.GUI().APIKey)
|
r.Header.Set("X-Api-Key", cfg.GUI().APIKey)
|
||||||
|
|
||||||
tr := &http.Transport{
|
tr := &http.Transport{
|
||||||
DialContext: dialer.DialContext,
|
DialContext: dialer.DialContext,
|
||||||
@@ -407,7 +407,7 @@ func upgradeViaRest() error {
|
|||||||
|
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
if resp.StatusCode != 200 {
|
if resp.StatusCode != http.StatusOK {
|
||||||
bs, err := io.ReadAll(resp.Body)
|
bs, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
+2
-2
@@ -546,7 +546,7 @@ func corsMiddleware(next http.Handler, allowFrameLoading bool) http.Handler {
|
|||||||
// See https://www.w3.org/TR/cors/ for details.
|
// See https://www.w3.org/TR/cors/ for details.
|
||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
// Process OPTIONS requests
|
// Process OPTIONS requests
|
||||||
if r.Method == "OPTIONS" {
|
if r.Method == http.MethodOptions {
|
||||||
// Add a generous access-control-allow-origin header for CORS requests
|
// Add a generous access-control-allow-origin header for CORS requests
|
||||||
w.Header().Add("Access-Control-Allow-Origin", "*")
|
w.Header().Add("Access-Control-Allow-Origin", "*")
|
||||||
// Only GET/POST/OPTIONS Methods are supported
|
// Only GET/POST/OPTIONS Methods are supported
|
||||||
@@ -557,7 +557,7 @@ func corsMiddleware(next http.Handler, allowFrameLoading bool) http.Handler {
|
|||||||
w.Header().Set("Access-Control-Max-Age", "600")
|
w.Header().Set("Access-Control-Max-Age", "600")
|
||||||
|
|
||||||
// Indicate that no content will be returned
|
// Indicate that no content will be returned
|
||||||
w.WriteHeader(204)
|
w.WriteHeader(http.StatusNoContent)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -173,7 +173,7 @@ func (p *Process) Get(path string) ([]byte, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
url := fmt.Sprintf("http://%s%s", p.addr, path)
|
url := fmt.Sprintf("http://%s%s", p.addr, path)
|
||||||
req, err := http.NewRequest("GET", url, nil)
|
req, err := http.NewRequest(http.MethodGet, url, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -198,7 +198,7 @@ func (p *Process) Post(path string, data io.Reader) ([]byte, error) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
url := fmt.Sprintf("http://%s%s", p.addr, path)
|
url := fmt.Sprintf("http://%s%s", p.addr, path)
|
||||||
req, err := http.NewRequest("POST", url, data)
|
req, err := http.NewRequest(http.MethodPost, url, data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -397,7 +397,7 @@ func (*Process) readResponse(resp *http.Response) ([]byte, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return bs, err
|
return bs, err
|
||||||
}
|
}
|
||||||
if resp.StatusCode != 200 {
|
if resp.StatusCode != http.StatusOK {
|
||||||
return bs, errors.New(resp.Status)
|
return bs, errors.New(resp.Status)
|
||||||
}
|
}
|
||||||
return bs, nil
|
return bs, nil
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ func (c *dynamicClient) serve(ctx context.Context) error {
|
|||||||
|
|
||||||
l.Debugln(c, "looking up dynamic relays")
|
l.Debugln(c, "looking up dynamic relays")
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, "GET", uri.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, uri.String(), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.Debugln(c, "failed to lookup dynamic relays", err)
|
l.Debugln(c, "failed to lookup dynamic relays", err)
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -222,7 +222,7 @@ func upgradeToURL(archiveName, binary string, url string) error {
|
|||||||
func readRelease(archiveName, dir, url string) (string, error) {
|
func readRelease(archiveName, dir, url string) (string, error) {
|
||||||
l.Debugf("loading %q", url)
|
l.Debugf("loading %q", url)
|
||||||
|
|
||||||
req, err := http.NewRequest("GET", url, nil)
|
req, err := http.NewRequest(http.MethodGet, url, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -578,7 +578,7 @@ func soapRequestWithIP(ctx context.Context, url, service, function, message stri
|
|||||||
|
|
||||||
body := fmt.Sprintf(template, message)
|
body := fmt.Sprintf(template, message)
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, "POST", url, strings.NewReader(body))
|
req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, strings.NewReader(body))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return resp, err
|
return resp, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -366,7 +366,7 @@ func (s *Service) sendUsageReport(ctx context.Context) error {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
req, err := http.NewRequestWithContext(ctx, "POST", s.cfg.Options().URURL, &b)
|
req, err := http.NewRequestWithContext(ctx, http.MethodPost, s.cfg.Options().URURL, &b)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user