Skip to content

Commit

Permalink
Merge pull request #14 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 f20f433 + 7263b57 commit c5c7aa2
Show file tree
Hide file tree
Showing 2 changed files with 11 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 = "gof"
)

var (
configFile string
)
Expand All @@ -23,6 +27,7 @@ type feed struct {
type config struct {
Accounts []account
LastUpdated time.Time
HttpConfig httpConfig
}

type account struct {
Expand All @@ -32,6 +37,10 @@ type account struct {
Feeds []feed
}

type httpConfig struct {
UserAgent string
}

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

Expand Down
1 change: 1 addition & 0 deletions message.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func (msg *message) post() error {
// Set Headers
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
req.Header.Set("Authorization", "Bearer "+msg.account.AccessToken)
req.Header.Set("User-Agent", conf.HttpConfig.UserAgent)

c := &http.Client{Timeout: time.Second * 10}

Expand Down

0 comments on commit c5c7aa2

Please sign in to comment.