nidus-sync/stadia/stadia.go
Eli Ribble 0ec810591e
lint: fix errcheck for Close and Write calls across multiple files
Use lint.LogOnErr for deferred Body/File/Client Close calls.
Use lint.Write for unchecked w.Write calls.
Fix bug in sync/sms.go where fmt.Errorf result was discarded
(replace with proper log.Error call).
2026-05-09 02:29:07 +00:00

44 lines
1 KiB
Go

package stadia
import (
"crypto/tls"
"github.com/Gleipnir-Technology/nidus-sync/lint"
"github.com/rs/zerolog/log"
"os"
"resty.dev/v3"
)
type StadiaMaps struct {
APIKey string
client *resty.Client
urlBaseApi string
urlBaseTiles string
}
func NewStadiaMaps(api_key string) *StadiaMaps {
//logger := NewLogger(log.Logger)
//r := resty.New().SetLogger(logger).SetDebug(true)
//r := resty.New().SetDebug(true)
r := resty.New()
if os.Getenv("STADIA_INSECURE_SKIP_VERIFY") != "" {
log.Warn().Msg("Using insecure TLS verification settings")
r.SetTLSClientConfig(&tls.Config{
InsecureSkipVerify: true,
})
}
return &StadiaMaps{
APIKey: api_key,
client: r,
urlBaseApi: "api.stadiamaps.com",
urlBaseTiles: "tiles.stadiamaps.com",
}
}
func (s *StadiaMaps) AddResponseMiddleware(m resty.ResponseMiddleware) {
s.client.SetResponseBodyUnlimitedReads(true)
s.client.AddResponseMiddleware(m)
}
func (s *StadiaMaps) Close() {
lint.LogOnErr(s.client.Close, "close stadia client")
}