From 5e4e76d5917947f27818b064dad275bc93900520 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 5 Apr 2024 14:46:46 +0200 Subject: [PATCH] Update kit version and http client --- envs/dev/api.air.toml | 2 +- envs/dev/cli.air.toml | 2 +- envs/dev/worker.air.toml | 2 +- go.mod | 2 +- go.sum | 4 ++-- pkg/example/services.go | 11 +++++++---- 6 files changed, 13 insertions(+), 10 deletions(-) diff --git a/envs/dev/api.air.toml b/envs/dev/api.air.toml index a785016..0d0fe5f 100644 --- a/envs/dev/api.air.toml +++ b/envs/dev/api.air.toml @@ -4,7 +4,7 @@ tmp_dir = "envs/dev/tmp" [build] # Just plain old shell command. You could use `make` as well. -cmd = "go build -a -tags netgo -ldflags '-w -extldflags \"-static\"' -o ./envs/dev/tmp/api ./cmd/api/*.go" +cmd = "go build -o ./envs/dev/tmp/api ./cmd/api/*.go" # Binary file yields from `cmd`. bin = "./envs/dev/tmp/api" # Customize binary. diff --git a/envs/dev/cli.air.toml b/envs/dev/cli.air.toml index 32954cb..66dd17d 100644 --- a/envs/dev/cli.air.toml +++ b/envs/dev/cli.air.toml @@ -4,7 +4,7 @@ tmp_dir = "envs/dev/tmp" [build] # Just plain old shell command. You could use `make` as well. -cmd = "go build -a -tags netgo -ldflags '-w -extldflags \"-static\"' -o ./envs/dev/tmp/cli ./cmd/cli/*.go" +cmd = "go build -o ./envs/dev/tmp/cli ./cmd/cli/*.go" # Binary file yields from `cmd`. bin = "./envs/dev/tmp/cli" # Customize binary. diff --git a/envs/dev/worker.air.toml b/envs/dev/worker.air.toml index 916f928..bac91f5 100644 --- a/envs/dev/worker.air.toml +++ b/envs/dev/worker.air.toml @@ -4,7 +4,7 @@ tmp_dir = "envs/dev/tmp" [build] # Just plain old shell command. You could use `make` as well. -cmd = "go build -a -tags netgo -ldflags '-w -extldflags \"-static\"' -o ./envs/dev/tmp/worker ./cmd/worker/*.go" +cmd = "go build -o ./envs/dev/tmp/worker ./cmd/worker/*.go" # Binary file yields from `cmd`. bin = "./envs/dev/tmp/worker" # Customize binary. diff --git a/go.mod b/go.mod index 057f569..5175698 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/leporo/sqlf v1.4.0 github.com/mkideal/cli v0.2.7 github.com/neoxelox/errors v0.2.0 - github.com/neoxelox/kit v0.26.0 + github.com/neoxelox/kit v0.29.0 github.com/rs/xid v1.5.0 golang.org/x/text v0.14.0 ) diff --git a/go.sum b/go.sum index d495dc5..333aa7e 100644 --- a/go.sum +++ b/go.sum @@ -221,8 +221,8 @@ github.com/neoxelox/errors v0.2.0 h1:AhvCMJAjUBFCP3PgZHbY6SS8Sc9fxx/DiawU5Cd5RxE github.com/neoxelox/errors v0.2.0/go.mod h1:gCPnC7z8Qwswwz5Usv3WORxvan9Q6WSrDTvzaQyl7oM= github.com/neoxelox/gilk v0.5.0 h1:Knw/TgSUnwPDIRJbqoTmG98gYsmKojNCJ5WAjALoWFc= github.com/neoxelox/gilk v0.5.0/go.mod h1:Q+WgmSMKWd5UAaVjLSmGPbVD11AmHFhlo3QrPum0vo0= -github.com/neoxelox/kit v0.26.0 h1:/F1UNoyV6+Eargg7/vyaiLhY1uIfTD/ikKn2eke7i0k= -github.com/neoxelox/kit v0.26.0/go.mod h1:IgYpZ0XID15bSpHXCnrJA6to5j69fzkbn0knfsEpdAE= +github.com/neoxelox/kit v0.29.0 h1:DPifgqzkFvej7efogdqUZ9/a6j2dcq51CfwaY6L8K2k= +github.com/neoxelox/kit v0.29.0/go.mod h1:IgYpZ0XID15bSpHXCnrJA6to5j69fzkbn0knfsEpdAE= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= diff --git a/pkg/example/services.go b/pkg/example/services.go index a204ab2..f711c93 100644 --- a/pkg/example/services.go +++ b/pkg/example/services.go @@ -3,7 +3,6 @@ package example import ( "context" "encoding/json" - "fmt" "time" "github.com/neoxelox/errors" @@ -30,7 +29,12 @@ type ExampleService struct { func NewExampleService(observer *kit.Observer, config config.Config) *ExampleService { client := kit.NewHTTPClient(observer, kit.HTTPClientConfig{ - Timeout: EXAMPLE_SERVICE_TIMEOUT, + Timeout: EXAMPLE_SERVICE_TIMEOUT, + BaseURL: util.Pointer(config.ExampleService.BaseURL), + Headers: util.Pointer(map[string]string{ + "Content-Type": "application/json", + }), + RaiseForStatus: util.Pointer(true), AllowedRedirects: util.Pointer(0), DefaultRetry: util.Pointer(kit.RetryConfig{ Attempts: 3, @@ -60,8 +64,7 @@ type ExampleServiceGetCountryResult struct { func (self *ExampleService) GetCountry(ctx context.Context, params ExampleServiceGetCountryParams) (*ExampleServiceGetCountryResult, error) { - response, err := self.client.Request( - ctx, "GET", fmt.Sprintf("%s/?name=%s", self.config.ExampleService.BaseURL, params.Name), nil) + response, err := self.client.Request(ctx, "GET", "/?name="+params.Name, nil, nil) if err != nil { if kit.ErrHTTPClientTimedOut.Is(err) { return nil, ErrExampleServiceTimedOut.Raise().Cause(err)