Replace http method strings with net/http constants (#14677)

This commit is contained in:
Anton Averchenkov
2022-03-24 13:58:03 -04:00
committed by GitHub
parent 7f36a29e04
commit 0dd4cda7c9
26 changed files with 142 additions and 109 deletions

View File

@@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"net/http"
"github.com/mitchellh/mapstructure"
)
@@ -16,7 +17,7 @@ func (c *Sys) ListAuthWithContext(ctx context.Context) (map[string]*AuthMount, e
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
defer cancelFunc()
r := c.c.NewRequest("GET", "/v1/sys/auth")
r := c.c.NewRequest(http.MethodGet, "/v1/sys/auth")
resp, err := c.c.rawRequestWithContext(ctx, r)
if err != nil {
@@ -57,7 +58,7 @@ func (c *Sys) EnableAuthWithOptionsWithContext(ctx context.Context, path string,
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
defer cancelFunc()
r := c.c.NewRequest("POST", fmt.Sprintf("/v1/sys/auth/%s", path))
r := c.c.NewRequest(http.MethodPost, fmt.Sprintf("/v1/sys/auth/%s", path))
if err := r.SetJSONBody(options); err != nil {
return err
}
@@ -79,7 +80,7 @@ func (c *Sys) DisableAuthWithContext(ctx context.Context, path string) error {
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
defer cancelFunc()
r := c.c.NewRequest("DELETE", fmt.Sprintf("/v1/sys/auth/%s", path))
r := c.c.NewRequest(http.MethodDelete, fmt.Sprintf("/v1/sys/auth/%s", path))
resp, err := c.c.rawRequestWithContext(ctx, r)
if err == nil {