Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add User-Agent header #14

Merged
merged 1 commit into from
Nov 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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