Skip to content

Commit

Permalink
patch extensions with latest gurl (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
fogfish authored Nov 11, 2024
1 parent 6e4d51a commit e7da7e9
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 30 deletions.
30 changes: 16 additions & 14 deletions x/awsapi/awsapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,19 @@ import (
"github.com/aws/aws-sdk-go-v2/credentials/stscreds"
"github.com/aws/aws-sdk-go-v2/service/sts"
"github.com/fogfish/gurl/v2/http"
"github.com/fogfish/opts"
)

// Configure HTTP Stack to use AWS Sign V4
func WithSignatureV4(conf aws.Config) http.Config {
return func(p *http.Protocol) {
p.Socket = &signer{
config: conf,
signer: v4.NewSigner(),
socket: p.Socket,
}
}
}
var WithSignatureV4 = opts.FMap(optsSigner)

// Configure HTTP Stack to use AWS Sign V4 using assumed role
func WithAssumedRole(conf aws.Config, role, externalID string) http.Config {
func WithAssumedRole(conf aws.Config, role, externalID string) http.Option {
if role == "" && externalID == "" {
return WithSignatureV4(conf)
}

return func(p *http.Protocol) {
return opts.From(func(p *http.Protocol) error {
assumed, err := config.LoadDefaultConfig(context.Background(),
config.WithCredentialsProvider(
aws.NewCredentialsCache(
Expand All @@ -57,11 +50,11 @@ func WithAssumedRole(conf aws.Config, role, externalID string) http.Config {
),
)
if err != nil {
panic(err)
return err
}

WithSignatureV4(assumed)(p)
}
return optsSigner(p, assumed)
})()
}

type signer struct {
Expand All @@ -70,6 +63,15 @@ type signer struct {
socket http.Socket
}

func optsSigner(p *http.Protocol, conf aws.Config) error {
p.Socket = &signer{
config: conf,
signer: v4.NewSigner(),
socket: p.Socket,
}
return nil
}

func (s *signer) Do(req *net.Request) (*net.Response, error) {
credential, err := s.config.Credentials.Retrieve(req.Context())
if err != nil {
Expand Down
7 changes: 5 additions & 2 deletions x/awsapi/go.mod
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
module github.com/fogfish/gurl/x/awsapi

go 1.21.0
go 1.23

require (
github.com/aws/aws-sdk-go-v2 v1.30.5
github.com/aws/aws-sdk-go-v2/config v1.27.33
github.com/aws/aws-sdk-go-v2/credentials v1.17.32
github.com/aws/aws-sdk-go-v2/service/sts v1.30.7
github.com/fogfish/gurl/v2 v2.8.3
github.com/fogfish/gurl/v2 v2.10.0
github.com/fogfish/opts v0.0.2
)

require (
Expand All @@ -21,5 +22,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/sso v1.22.7 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.26.7 // indirect
github.com/aws/smithy-go v1.20.4 // indirect
github.com/fogfish/golem/hseq v1.2.0 // indirect
github.com/fogfish/golem/optics v0.13.1 // indirect
golang.org/x/net v0.17.0 // indirect
)
14 changes: 10 additions & 4 deletions x/awsapi/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,16 @@ github.com/aws/aws-sdk-go-v2/service/sts v1.30.7 h1:NKTa1eqZYw8tiHSRGpP0VtTdub/8
github.com/aws/aws-sdk-go-v2/service/sts v1.30.7/go.mod h1:NXi1dIAGteSaRLqYgarlhP/Ij0cFT+qmCwiJqWh/U5o=
github.com/aws/smithy-go v1.20.4 h1:2HK1zBdPgRbjFOHlfeQZfpC4r72MOb9bZkiFwggKO+4=
github.com/aws/smithy-go v1.20.4/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg=
github.com/fogfish/gurl/v2 v2.8.3 h1:CH8dOHz+lMPg3M0/S5bWk5z3RD9FG4L8+uQMEv36ibU=
github.com/fogfish/gurl/v2 v2.8.3/go.mod h1:VDPaGeyMSZsbFByZXwKZuwKgOC1mOQNlOYhM4RgOVWQ=
github.com/fogfish/it/v2 v2.0.1 h1:vu3kV2xzYDPHoMHMABxXeu5CoMcTfRc4gkWkzOUkRJY=
github.com/fogfish/it/v2 v2.0.1/go.mod h1:h5FdKaEQT4sUEykiVkB8VV4jX27XabFVeWhoDZaRZtE=
github.com/fogfish/golem/hseq v1.2.0 h1:B6yrzOHQNoTqSlhLb+AvK7dhEAELjHThrCQTF/uqwbM=
github.com/fogfish/golem/hseq v1.2.0/go.mod h1:17XORt8nNKl6KOhF43MHSmjK8NksbkBsohAoJGiinUs=
github.com/fogfish/golem/optics v0.13.1 h1:gkvJ5f7/AXaL8EuHLu5dgE/BwUSg/WX50D7b8f4G+6s=
github.com/fogfish/golem/optics v0.13.1/go.mod h1:U1y90OVcXF/A61dIP3abQ0x2GweTmzVHPC15pv0pcM0=
github.com/fogfish/gurl/v2 v2.10.0 h1:91qNyuYG6H+qHEqrPIogct1e8WUeH/QUFWrBG7+u5i8=
github.com/fogfish/gurl/v2 v2.10.0/go.mod h1:7T4FFZiWmEXVYnTgSdqEbAM/bwPfWSkEYgaVAsVSIso=
github.com/fogfish/it/v2 v2.0.2 h1:UR6yVemf8zD3WVs6Bq0zE6LJwapZ8urv9zvU5VB5E6o=
github.com/fogfish/it/v2 v2.0.2/go.mod h1:HHwufnTaZTvlRVnSesPl49HzzlMrQtweKbf+8Co/ll4=
github.com/fogfish/opts v0.0.2 h1:Iro+QQHR/l6G5afX6N5TtqZtV+iVeUxJUOpW63gqhwk=
github.com/fogfish/opts v0.0.2/go.mod h1:fAM7yksrn+u5opbyAh2HiObd5Zx54WnSMGZIU21AGFw=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
Expand Down
2 changes: 1 addition & 1 deletion x/awsapi/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@

package awsapi

const Version = "x/awsapi/v0.0.4"
const Version = "x/awsapi/v0.0.5"
9 changes: 6 additions & 3 deletions x/xhtml/go.mod
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
module github.com/fogfish/gurl/x/xhtml

go 1.21.0
go 1.23

require (
github.com/PuerkitoBio/goquery v1.9.1
github.com/fogfish/gurl/v2 v2.9.0
github.com/fogfish/it/v2 v2.0.1
github.com/fogfish/gurl/v2 v2.10.0
github.com/fogfish/it/v2 v2.0.2
)

require (
github.com/ajg/form v1.5.2-0.20200323032839-9aeb3cf462e1 // indirect
github.com/andybalholm/cascadia v1.3.2 // indirect
github.com/fogfish/golem/hseq v1.2.0 // indirect
github.com/fogfish/golem/optics v0.13.1 // indirect
github.com/fogfish/opts v0.0.2 // indirect
github.com/google/go-cmp v0.6.0 // indirect
golang.org/x/net v0.21.0 // indirect
)
14 changes: 10 additions & 4 deletions x/xhtml/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@ github.com/ajg/form v1.5.2-0.20200323032839-9aeb3cf462e1 h1:8Qzi+0Uch1VJvdrOhJ8U
github.com/ajg/form v1.5.2-0.20200323032839-9aeb3cf462e1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY=
github.com/andybalholm/cascadia v1.3.2 h1:3Xi6Dw5lHF15JtdcmAHD3i1+T8plmv7BQ/nsViSLyss=
github.com/andybalholm/cascadia v1.3.2/go.mod h1:7gtRlve5FxPPgIgX36uWBX58OdBsSS6lUvCFb+h7KvU=
github.com/fogfish/gurl/v2 v2.9.0 h1:IZlOxZte9y+NFgKHkPYw5jS0VCNG9avu2Ywrm2c3S6k=
github.com/fogfish/gurl/v2 v2.9.0/go.mod h1:vBqw+SCrfOPNllWDCwPnuotrNeuuyTsYZ28iP13qF3Y=
github.com/fogfish/it/v2 v2.0.1 h1:vu3kV2xzYDPHoMHMABxXeu5CoMcTfRc4gkWkzOUkRJY=
github.com/fogfish/it/v2 v2.0.1/go.mod h1:h5FdKaEQT4sUEykiVkB8VV4jX27XabFVeWhoDZaRZtE=
github.com/fogfish/golem/hseq v1.2.0 h1:B6yrzOHQNoTqSlhLb+AvK7dhEAELjHThrCQTF/uqwbM=
github.com/fogfish/golem/hseq v1.2.0/go.mod h1:17XORt8nNKl6KOhF43MHSmjK8NksbkBsohAoJGiinUs=
github.com/fogfish/golem/optics v0.13.1 h1:gkvJ5f7/AXaL8EuHLu5dgE/BwUSg/WX50D7b8f4G+6s=
github.com/fogfish/golem/optics v0.13.1/go.mod h1:U1y90OVcXF/A61dIP3abQ0x2GweTmzVHPC15pv0pcM0=
github.com/fogfish/gurl/v2 v2.10.0 h1:91qNyuYG6H+qHEqrPIogct1e8WUeH/QUFWrBG7+u5i8=
github.com/fogfish/gurl/v2 v2.10.0/go.mod h1:7T4FFZiWmEXVYnTgSdqEbAM/bwPfWSkEYgaVAsVSIso=
github.com/fogfish/it/v2 v2.0.2 h1:UR6yVemf8zD3WVs6Bq0zE6LJwapZ8urv9zvU5VB5E6o=
github.com/fogfish/it/v2 v2.0.2/go.mod h1:HHwufnTaZTvlRVnSesPl49HzzlMrQtweKbf+8Co/ll4=
github.com/fogfish/opts v0.0.2 h1:Iro+QQHR/l6G5afX6N5TtqZtV+iVeUxJUOpW63gqhwk=
github.com/fogfish/opts v0.0.2/go.mod h1:fAM7yksrn+u5opbyAh2HiObd5Zx54WnSMGZIU21AGFw=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
Expand Down
2 changes: 1 addition & 1 deletion x/xhtml/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@

package xhtml

const Version = "x/xhtml/v0.0.2"
const Version = "x/xhtml/v0.0.3"
2 changes: 1 addition & 1 deletion x/xhtml/xhtml.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type Client struct {

// Create new instance of HTTP Client tailored for fetching HTML content
// from public resources.
func New(opts ...http.Config) Client {
func New(opts ...http.Option) Client {
return Client{Stack: http.New(opts...)}
}

Expand Down

0 comments on commit e7da7e9

Please sign in to comment.