Skip to content

Commit dd17ec6

Browse files
committed
Refactor API key header handling and update status codes.
Replaced `httputilsserver.XApiKey` with `api_context.XApiKey` for consistency across modules. Adjusted expected HTTP status in `cmd/stream/main.go` to `http.StatusOK`. Cleaned up redundant module entries in `go.mod` and `go.sum`.
1 parent a9603ce commit dd17ec6

5 files changed

Lines changed: 6 additions & 16 deletions

File tree

cmd/cli/connect/get_peer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package connect
22

33
import (
4+
"github.com/softwareplace/http-utils/api_context"
45
"github.com/softwareplace/http-utils/request"
5-
httputilsserver "github.com/softwareplace/http-utils/server"
66
"github.com/softwareplace/wireguard-api/cmd/cli/spec"
77
"github.com/softwareplace/wireguard-api/pkg/models"
88
"log"
@@ -14,7 +14,7 @@ func GetPeer(profile *spec.Profile, server *spec.Server) models.Peer {
1414

1515
apiConfig := request.Build(server.Host).
1616
WithPath("/peers").
17-
WithHeader(httputilsserver.XApiKey, server.ApiKey).
17+
WithHeader(api_context.XApiKey, server.ApiKey).
1818
WithHeader("Authorization", profile.AuthorizationKey).
1919
WithExpectedStatusCode(http.StatusOK)
2020

cmd/cli/connect/login.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package connect
22

33
import (
44
"fmt"
5+
"github.com/softwareplace/http-utils/api_context"
56
"github.com/softwareplace/http-utils/request"
6-
httputilsserver "github.com/softwareplace/http-utils/server"
77
"github.com/softwareplace/wireguard-api/cmd/cli/shared"
88
"github.com/softwareplace/wireguard-api/cmd/cli/spec"
99
"github.com/softwareplace/wireguard-api/pkg/utils/sec"
@@ -76,7 +76,7 @@ func Login(args *shared.Args, profile *spec.Profile, server spec.Server) {
7676
config := request.Build(server.Host).
7777
WithPath("/login").
7878
WithBody(reqBody).
79-
WithHeader(httputilsserver.XApiKey, server.ApiKey).
79+
WithHeader(api_context.XApiKey, server.ApiKey).
8080
WithExpectedStatusCode(http.StatusOK)
8181

8282
loginResp, err := api.Post(config)

cmd/stream/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func main() {
5353
WithHeader("Authorization", streamEnv.Authorization).
5454
WithHeader(api_context.XApiKey, streamEnv.ApiKey).
5555
WithBody(dump).
56-
WithExpectedStatusCode(http.StatusCreated)
56+
WithExpectedStatusCode(http.StatusOK)
5757

5858
_, err = api.Post(config)
5959
if err != nil {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ go 1.23
55
toolchain go1.23.4
66

77
require (
8-
github.com/softwareplace/http-utils v0.0.0-20250118003817-f2b4ec9b8676
98
github.com/atotto/clipboard v0.1.4
109
github.com/google/uuid v1.6.0
10+
github.com/softwareplace/http-utils v0.0.0-20250118003817-f2b4ec9b8676
1111
go.mongodb.org/mongo-driver v1.17.2
1212
golang.org/x/crypto v0.32.0
1313
gopkg.in/yaml.v3 v3.0.1

go.sum

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,6 @@ github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IX
1616
github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
1717
github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8eaE=
1818
github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow=
19-
github.com/softwareplace/http-utils v0.0.0-20250116230044-ed510c97fc93 h1:ozum1P9qUdOMrItHokPNVHbOHZNObM2s2fYBWo3bxe0=
20-
github.com/softwareplace/http-utils v0.0.0-20250116230044-ed510c97fc93/go.mod h1:GhSRH3bwg1iK6CZl3IwjPol9t+QctcPrVPc3mvZmQ7Q=
21-
github.com/softwareplace/http-utils v0.0.0-20250116232827-e496aa73762e h1:PngEYXx329HwewdTbn/g0iKcozTlvR0Y61a+1Q2fYtE=
22-
github.com/softwareplace/http-utils v0.0.0-20250116232827-e496aa73762e/go.mod h1:GhSRH3bwg1iK6CZl3IwjPol9t+QctcPrVPc3mvZmQ7Q=
23-
github.com/softwareplace/http-utils v0.0.0-20250117012334-addd8fbd1220 h1:4CYLGGScSzkWEnV5rxbgGmEWpYcPwgpXb958LnXp3+g=
24-
github.com/softwareplace/http-utils v0.0.0-20250117012334-addd8fbd1220/go.mod h1:GhSRH3bwg1iK6CZl3IwjPol9t+QctcPrVPc3mvZmQ7Q=
25-
github.com/softwareplace/http-utils v0.0.0-20250117224835-13ee112340a6 h1:uxMnbpDzjwnTeJNT9W5NZzkbITRG1CzS5BbkLMD39k0=
26-
github.com/softwareplace/http-utils v0.0.0-20250117224835-13ee112340a6/go.mod h1:5o/vgMsC67X2DChcdR76qm8yyjkIKmSFHudNeaK060U=
27-
github.com/softwareplace/http-utils v0.0.0-20250117231145-c67f294855cd h1:NTHsh5xr4DlIGwaNrEuq7vREYryGPZol7qFYsQgPl8s=
28-
github.com/softwareplace/http-utils v0.0.0-20250117231145-c67f294855cd/go.mod h1:5o/vgMsC67X2DChcdR76qm8yyjkIKmSFHudNeaK060U=
2919
github.com/softwareplace/http-utils v0.0.0-20250118003817-f2b4ec9b8676 h1:pTZv6az0E/CQBbVXUROyWQjdaFyamMMkz2YYvRf9CmI=
3020
github.com/softwareplace/http-utils v0.0.0-20250118003817-f2b4ec9b8676/go.mod h1:5o/vgMsC67X2DChcdR76qm8yyjkIKmSFHudNeaK060U=
3121
github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c=

0 commit comments

Comments
 (0)