Skip to content

Commit fb98f0b

Browse files
authored
Merge pull request #853 from nyaruka/update_gocommon
Update to latest gocommon
2 parents 5815432 + e82d235 commit fb98f0b

File tree

5 files changed

+36
-32
lines changed

5 files changed

+36
-32
lines changed

go.mod

+9-9
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ require (
1111
github.com/buger/jsonparser v1.1.1
1212
github.com/getsentry/sentry-go v0.31.1
1313
github.com/go-chi/chi/v5 v5.2.1
14-
github.com/golang-jwt/jwt/v5 v5.2.1
14+
github.com/golang-jwt/jwt/v5 v5.2.2
1515
github.com/gomodule/redigo v1.9.2
1616
github.com/gorilla/schema v1.4.1
1717
github.com/h2non/filetype v1.1.3
1818
github.com/jmoiron/sqlx v1.4.0
1919
github.com/lib/pq v1.10.9
2020
github.com/nyaruka/ezconf v0.3.0
21-
github.com/nyaruka/gocommon v1.60.5
21+
github.com/nyaruka/gocommon v1.61.1
2222
github.com/nyaruka/null/v3 v3.0.0
2323
github.com/nyaruka/redisx v0.9.0
2424
github.com/patrickmn/go-cache v2.1.0+incompatible
@@ -34,8 +34,8 @@ require (
3434
cloud.google.com/go/compute/metadata v0.6.0 // indirect
3535
github.com/antchfx/xpath v1.3.3 // indirect
3636
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.10 // indirect
37-
github.com/aws/aws-sdk-go-v2/config v1.29.9 // indirect
38-
github.com/aws/aws-sdk-go-v2/credentials v1.17.62 // indirect
37+
github.com/aws/aws-sdk-go-v2/config v1.29.12 // indirect
38+
github.com/aws/aws-sdk-go-v2/credentials v1.17.65 // indirect
3939
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.30 // indirect
4040
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.34 // indirect
4141
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.34 // indirect
@@ -48,16 +48,16 @@ require (
4848
github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.10.15 // indirect
4949
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.15 // indirect
5050
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.15 // indirect
51-
github.com/aws/aws-sdk-go-v2/service/sso v1.25.1 // indirect
52-
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.29.1 // indirect
51+
github.com/aws/aws-sdk-go-v2/service/sso v1.25.2 // indirect
52+
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.30.0 // indirect
5353
github.com/aws/aws-sdk-go-v2/service/sts v1.33.17 // indirect
5454
github.com/aws/smithy-go v1.22.3 // indirect
5555
github.com/davecgh/go-spew v1.1.1 // indirect
5656
github.com/fatih/structs v1.1.0 // indirect
5757
github.com/gabriel-vasile/mimetype v1.4.8 // indirect
5858
github.com/go-playground/locales v0.14.1 // indirect
5959
github.com/go-playground/universal-translator v0.18.1 // indirect
60-
github.com/go-playground/validator/v10 v10.25.0 // indirect
60+
github.com/go-playground/validator/v10 v10.26.0 // indirect
6161
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
6262
github.com/google/uuid v1.6.0 // indirect
6363
github.com/gorilla/websocket v1.5.3 // indirect
@@ -74,11 +74,11 @@ require (
7474
github.com/shopspring/decimal v1.4.0 // indirect
7575
golang.org/x/crypto v0.36.0 // indirect
7676
golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 // indirect
77-
golang.org/x/net v0.37.0 // indirect
77+
golang.org/x/net v0.38.0 // indirect
7878
golang.org/x/sync v0.12.0 // indirect
7979
golang.org/x/sys v0.31.0 // indirect
8080
golang.org/x/text v0.23.0 // indirect
81-
google.golang.org/protobuf v1.36.5 // indirect
81+
google.golang.org/protobuf v1.36.6 // indirect
8282
gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
8383
gopkg.in/yaml.v3 v3.0.1 // indirect
8484
)

go.sum

+18-16
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ github.com/aws/aws-sdk-go-v2 v1.36.3 h1:mJoei2CxPutQVxaATCzDUjcZEjVRdpsiiXi2o38y
1010
github.com/aws/aws-sdk-go-v2 v1.36.3/go.mod h1:LLXuLpgzEbD766Z5ECcRmi8AzSwfZItDtmABVkRLGzg=
1111
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.10 h1:zAybnyUQXIZ5mok5Jqwlf58/TFE7uvd3IAsa1aF9cXs=
1212
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.10/go.mod h1:qqvMj6gHLR/EXWZw4ZbqlPbQUyenf4h82UQUlKc+l14=
13-
github.com/aws/aws-sdk-go-v2/config v1.29.9 h1:Kg+fAYNaJeGXp1vmjtidss8O2uXIsXwaRqsQJKXVr+0=
14-
github.com/aws/aws-sdk-go-v2/config v1.29.9/go.mod h1:oU3jj2O53kgOU4TXq/yipt6ryiooYjlkqqVaZk7gY/U=
15-
github.com/aws/aws-sdk-go-v2/credentials v1.17.62 h1:fvtQY3zFzYJ9CfixuAQ96IxDrBajbBWGqjNTCa79ocU=
16-
github.com/aws/aws-sdk-go-v2/credentials v1.17.62/go.mod h1:ElETBxIQqcxej++Cs8GyPBbgMys5DgQPTwo7cUPDKt8=
13+
github.com/aws/aws-sdk-go-v2/config v1.29.12 h1:Y/2a+jLPrPbHpFkpAAYkVEtJmxORlXoo5k2g1fa2sUo=
14+
github.com/aws/aws-sdk-go-v2/config v1.29.12/go.mod h1:xse1YTjmORlb/6fhkWi8qJh3cvZi4JoVNhc+NbJt4kI=
15+
github.com/aws/aws-sdk-go-v2/credentials v1.17.65 h1:q+nV2yYegofO/SUXruT+pn4KxkxmaQ++1B/QedcKBFM=
16+
github.com/aws/aws-sdk-go-v2/credentials v1.17.65/go.mod h1:4zyjAuGOdikpNYiSGpsGz8hLGmUzlY8pc8r9QQ/RXYQ=
1717
github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.18.8 h1:hGcg4DGGO+kolelCoOfuS7DGdySfx1vDe6QQsuuYKRU=
1818
github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.18.8/go.mod h1:fpFbG/4VQvI/DXpY5tG+CEtRZ2DDfi6krAI4sUj8aFE=
1919
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.30 h1:x793wxmUWVDhshP8WW2mlnXuFrO4cOd3HLBroh1paFw=
@@ -44,10 +44,10 @@ github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.15 h1:moLQUoVq91Liq
4444
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.15/go.mod h1:ZH34PJUc8ApjBIfgQCFvkWcUDBtl/WTD+uiYHjd8igA=
4545
github.com/aws/aws-sdk-go-v2/service/s3 v1.78.2 h1:jIiopHEV22b4yQP2q36Y0OmwLbsxNWdWwfZRR5QRRO4=
4646
github.com/aws/aws-sdk-go-v2/service/s3 v1.78.2/go.mod h1:U5SNqwhXB3Xe6F47kXvWihPl/ilGaEDe8HD/50Z9wxc=
47-
github.com/aws/aws-sdk-go-v2/service/sso v1.25.1 h1:8JdC7Gr9NROg1Rusk25IcZeTO59zLxsKgE0gkh5O6h0=
48-
github.com/aws/aws-sdk-go-v2/service/sso v1.25.1/go.mod h1:qs4a9T5EMLl/Cajiw2TcbNt2UNo/Hqlyp+GiuG4CFDI=
49-
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.29.1 h1:KwuLovgQPcdjNMfFt9OhUd9a2OwcOKhxfvF4glTzLuA=
50-
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.29.1/go.mod h1:MlYRNmYu/fGPoxBQVvBYr9nyr948aY/WLUvwBMBJubs=
47+
github.com/aws/aws-sdk-go-v2/service/sso v1.25.2 h1:pdgODsAhGo4dvzC3JAG5Ce0PX8kWXrTZGx+jxADD+5E=
48+
github.com/aws/aws-sdk-go-v2/service/sso v1.25.2/go.mod h1:qs4a9T5EMLl/Cajiw2TcbNt2UNo/Hqlyp+GiuG4CFDI=
49+
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.30.0 h1:90uX0veLKcdHVfvxhkWUQSCi5VabtwMLFutYiRke4oo=
50+
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.30.0/go.mod h1:MlYRNmYu/fGPoxBQVvBYr9nyr948aY/WLUvwBMBJubs=
5151
github.com/aws/aws-sdk-go-v2/service/sts v1.33.17 h1:PZV5W8yk4OtH1JAuhV2PXwwO9v5G5Aoj+eMCn4T+1Kc=
5252
github.com/aws/aws-sdk-go-v2/service/sts v1.33.17/go.mod h1:cQnB8CUnxbMU82JvlqjKR2HBOm3fe9pWorWBza6MBJ4=
5353
github.com/aws/smithy-go v1.22.3 h1:Z//5NuZCSW6R4PhQ93hShNbyBbn8BWCmCVCt+Q8Io5k=
@@ -72,12 +72,14 @@ github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/o
7272
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
7373
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
7474
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
75-
github.com/go-playground/validator/v10 v10.25.0 h1:5Dh7cjvzR7BRZadnsVOzPhWsrwUr0nmsZJxEAnFLNO8=
76-
github.com/go-playground/validator/v10 v10.25.0/go.mod h1:GGzBIJMuE98Ic/kJsBXbz1x/7cByt++cQ+YOuDM5wus=
75+
github.com/go-playground/validator/v10 v10.26.0 h1:SP05Nqhjcvz81uJaRfEV0YBSSSGMc/iMaVtFbr3Sw2k=
76+
github.com/go-playground/validator/v10 v10.26.0/go.mod h1:I5QpIEbmr8On7W0TktmJAumgzX4CA1XNl4ZmDuVHKKo=
7777
github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y=
7878
github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
7979
github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk=
8080
github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
81+
github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8=
82+
github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
8183
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
8284
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 h1:f+oWsMOmNPc8JmEHVZIycC7hBoQxHH9pNKQORJNozsQ=
8385
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8/go.mod h1:wcDNUvekVysuuOpQKo3191zZyTpiI6se1N1ULghS0sw=
@@ -115,8 +117,8 @@ github.com/naoina/toml v0.1.1 h1:PT/lllxVVN0gzzSqSlHEmP8MJB4MY2U7STGxiouV4X8=
115117
github.com/naoina/toml v0.1.1/go.mod h1:NBIhNtsFMo3G2szEBne+bO4gS192HuIYRqfvOWb4i1E=
116118
github.com/nyaruka/ezconf v0.3.0 h1:kGvJqVN8AHowb4HdaHAviJ0Z3yI5Pyekp1WqibFEaGk=
117119
github.com/nyaruka/ezconf v0.3.0/go.mod h1:89GUW6EPRNLIxT7lC4LWnjWTgZeQwRoX7lBmc8ralAU=
118-
github.com/nyaruka/gocommon v1.60.5 h1:V10rosGzVArRspilfbi65TyHBZzjLQbwmaBeicr2Drw=
119-
github.com/nyaruka/gocommon v1.60.5/go.mod h1:kFJuOq8COneV7ssfK6xgCMJ8gP8fQifLQnNXBnE4YL0=
120+
github.com/nyaruka/gocommon v1.61.1 h1:qulMx0jHDWoDagCJbVs7CMLZA33jfa5kYutlXR66pHM=
121+
github.com/nyaruka/gocommon v1.61.1/go.mod h1:HcwpCzwt8XK7SxmGHYRF1R9viOAvlU7VtXTGuEmJx/8=
120122
github.com/nyaruka/null/v2 v2.0.3 h1:rdmMRQyVzrOF3Jff/gpU/7BDR9mQX0lcLl4yImsA3kw=
121123
github.com/nyaruka/null/v2 v2.0.3/go.mod h1:OCVeCkCXwrg5/qE6RU0c1oUVZBy+ZDrT+xYg1XSaIWA=
122124
github.com/nyaruka/null/v3 v3.0.0 h1:JvOiNuKmRBFHxzZFt4sWii+ewmMkCQ1vO7X0clTNn6E=
@@ -176,8 +178,8 @@ golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
176178
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
177179
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
178180
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
179-
golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c=
180-
golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
181+
golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8=
182+
golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
181183
golang.org/x/oauth2 v0.28.0 h1:CrgCKl8PPAVtLnU3c+EDw6x11699EWlsDeWNWKdIOkc=
182184
golang.org/x/oauth2 v0.28.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8=
183185
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -229,8 +231,8 @@ golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
229231
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
230232
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
231233
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
232-
google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM=
233-
google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
234+
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
235+
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
234236
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
235237
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
236238
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=

handlers/africastalking/handler.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/buger/jsonparser"
1212
"github.com/nyaruka/courier"
1313
"github.com/nyaruka/courier/handlers"
14+
"github.com/nyaruka/gocommon/httpx"
1415
"github.com/nyaruka/gocommon/urns"
1516
)
1617

@@ -138,13 +139,14 @@ func (h *handler) Send(ctx context.Context, msg courier.MsgOut, res *courier.Sen
138139
form["from"] = []string{msg.Channel().Address()}
139140
}
140141

141-
req, err := http.NewRequest(http.MethodPost, sendURL, strings.NewReader(form.Encode()))
142+
req, err := httpx.NewRequest(ctx, http.MethodPost, sendURL, strings.NewReader(form.Encode()), map[string]string{
143+
"Content-Type": "application/x-www-form-urlencoded",
144+
"Accept": "application/json",
145+
"apikey": apiKey,
146+
})
142147
if err != nil {
143148
return err
144149
}
145-
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
146-
req.Header.Set("Accept", "application/json")
147-
req.Header.Set("apikey", apiKey)
148150

149151
resp, respBody, err := h.RequestHTTP(req, clog)
150152
if err != nil || resp.StatusCode/100 == 5 {

test/handler.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func (h *mockHandler) Initialize(s courier.Server) error {
4747
// Send sends the given message, logging any HTTP calls or errors
4848
func (h *mockHandler) Send(ctx context.Context, msg courier.MsgOut, res *courier.SendResult, clog *courier.ChannelLog) error {
4949
// log a request that contains a header value that should be redacted
50-
req, _ := httpx.NewRequest("GET", "http://mock.com/send", nil, map[string]string{"Authorization": "Token sesame"})
50+
req, _ := httpx.NewRequest(ctx, "GET", "http://mock.com/send", nil, map[string]string{"Authorization": "Token sesame"})
5151
trace, err := httpx.DoTrace(http.DefaultClient, req, nil, nil, 1024)
5252
clog.HTTP(trace)
5353

utils/clogs/clog_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ func TestLogs(t *testing.T) {
2626
clog1 := clogs.New("type1", nil, []string{"sesame"})
2727
clog2 := clogs.New("type1", nil, []string{"sesame"})
2828

29-
req1, _ := httpx.NewRequest("GET", "http://ivr.com/start", nil, map[string]string{"Authorization": "Token sesame"})
29+
req1, _ := httpx.NewRequest(ctx, "GET", "http://ivr.com/start", nil, map[string]string{"Authorization": "Token sesame"})
3030
trace1, err := httpx.DoTrace(http.DefaultClient, req1, nil, nil, -1)
3131
require.NoError(t, err)
3232

3333
clog1.HTTP(trace1)
3434
clog1.End()
3535

36-
req2, _ := httpx.NewRequest("GET", "http://ivr.com/hangup", nil, nil)
36+
req2, _ := httpx.NewRequest(ctx, "GET", "http://ivr.com/hangup", nil, nil)
3737
trace2, err := httpx.DoTrace(http.DefaultClient, req2, nil, nil, -1)
3838
require.NoError(t, err)
3939

0 commit comments

Comments
 (0)