Skip to content

Commit

Permalink
Merge pull request #17 from prplecake/ua-header
Browse files Browse the repository at this point in the history
  • Loading branch information
prplecake authored Nov 24, 2022
2 parents 73db2ce + d28911f commit d62f48a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import (
"gopkg.in/yaml.v2"
)

const (
HttpUserAgent = "mastodon-bookmark-sync/1.0"
)

var (
configFile string
)
Expand All @@ -16,6 +20,7 @@ type config struct {
Instances []instanceConfig
Pinboard pinboardConfig
LastSynced time.Time
HttpConfig httpConfig
}

type instanceConfig struct {
Expand All @@ -27,6 +32,10 @@ type pinboardConfig struct {
APIToken string
}

type httpConfig struct {
UserAgent string
}

func readConfig(fileName string) *config {
log.Println("reading config...")
configFile = fileName
Expand All @@ -42,6 +51,7 @@ func readConfig(fileName string) *config {
if debug {
log.Printf("Config:\n\n%v", config)
}
config.HttpConfig.UserAgent = HttpUserAgent
return config
}

Expand Down
2 changes: 2 additions & 0 deletions mastodon-bookmark-sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func main() {
log.Fatal(err)
}
req.Header.Set("Authorization", "Bearer "+instance.AccessToken)
req.Header.Set("User-Agent", conf.HttpConfig.UserAgent)

c := &http.Client{}

Expand Down Expand Up @@ -120,6 +121,7 @@ func main() {
if err != nil {
log.Fatal(err)
}
req.Header.Set("User-Agent", conf.HttpConfig.UserAgent)

c := &http.Client{}

Expand Down

0 comments on commit d62f48a

Please sign in to comment.