M client/graphql.go => client/graphql.go +1 -1
@@ 129,7 129,7 @@ func Do(ctx context.Context, username string, svc string,
req.Header.Add("Content-Type", contentType)
req.Header.Add("User-Agent",
fmt.Sprintf("%s -- SourceHut core-go (https://git.sr.ht/~sircmpwn/core-go)",
- config.ServiceName(ctx)))
+ config.ServiceName(ctx)))
auth := InternalAuth{
Name: username,
ClientID: config.ServiceName(ctx),
M objects/middleware.go => objects/middleware.go +8 -1
@@ 11,6 11,8 @@ import (
"github.com/aws/aws-sdk-go-v2/service/s3"
"github.com/aws/smithy-go/endpoints"
"github.com/vaughan0/go-ini"
+
+ "git.sr.ht/~sircmpwn/core-go/config"
)
var s3CtxKey = &contextKey{"s3"}
@@ 76,12 78,17 @@ func NewClient(conf ini.File) (*s3.Client, error) {
region = "default"
}
+ scheme := "https://"
+ if config.GetBool(conf, "objects", "s3-insecure", false) {
+ scheme = "http://"
+ }
+
creds := credentials.NewStaticCredentialsProvider(accessKey, secretKey, "")
return s3.NewFromConfig(aws.Config{
Region: region,
Credentials: creds,
}, func(opts *s3.Options) {
- opts.BaseEndpoint = aws.String("https://" + upstream)
+ opts.BaseEndpoint = aws.String(scheme + upstream)
opts.EndpointResolverV2 = &S3Resolver{
conf,
s3.NewDefaultEndpointResolverV2(),