Skip to content
This repository has been archived by the owner on Jun 10, 2021. It is now read-only.

Commit

Permalink
fix: rename function and make field anonymous
Browse files Browse the repository at this point in the history
  • Loading branch information
freemountain committed Jun 23, 2018
1 parent 6f9d51e commit 6bf6db8
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions cmd/emuarius/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ type TwitterConfig struct {
AccessTokenSecret string `toml:"accessTokenSecret"`
}
type Config struct {
DatabasePath string `toml:"databasePath"`
Address string `toml:"address"`
RootURL string `toml:"rootURL"`
TwitterConfig `toml:"twitter"`
DatabasePath string `toml:"databasePath"`
Address string `toml:"address"`
RootURL string `toml:"rootURL"`
Twitter TwitterConfig `toml:"twitter"`
}

func getFirstNonEmpty(params ...string) string {
Expand All @@ -50,7 +50,7 @@ func readToml(path string) Config {
return cfg
}

func getHerokuAddress() string {
func getAddress() string {
var port = os.Getenv("PORT")

if port != "" {
Expand All @@ -65,13 +65,13 @@ func getConf(path string) Config {

return Config{
DatabasePath: getFirstNonEmpty(os.Getenv("EMUARIUS_DATABASE_PATH"), toml.DatabasePath, "./emuarius.db"),
Address: getFirstNonEmpty(os.Getenv("EMUARIUS_ADDRESS"), toml.Address, getHerokuAddress(), ":4004"),
Address: getFirstNonEmpty(os.Getenv("EMUARIUS_ADDRESS"), toml.Address, getAddress(), ":4004"),
RootURL: getFirstNonEmpty(os.Getenv("EMUARIUS_ROOT_URL"), toml.RootURL, "http://localhost:4004"),
TwitterConfig: TwitterConfig{
ConsumerKey: getFirstNonEmpty(os.Getenv("EMUARIUS_TWITTER_CONSUMER_KEY"), toml.TwitterConfig.ConsumerKey),
ConsumerSecret: getFirstNonEmpty(os.Getenv("EMUARIUS_TWITTER_CONSUMER_SECRET"), toml.TwitterConfig.ConsumerSecret),
AccessToken: getFirstNonEmpty(os.Getenv("EMUARIUS_TWITTER_ACCESS_TOKEN"), toml.TwitterConfig.AccessToken),
AccessTokenSecret: getFirstNonEmpty(os.Getenv("EMUARIUS_TWITTER_ACCESS_TOKEN_SECRET"), toml.TwitterConfig.AccessTokenSecret),
Twitter: TwitterConfig{
ConsumerKey: getFirstNonEmpty(os.Getenv("EMUARIUS_TWITTER_CONSUMER_KEY"), toml.Twitter.ConsumerKey),
ConsumerSecret: getFirstNonEmpty(os.Getenv("EMUARIUS_TWITTER_CONSUMER_SECRET"), toml.Twitter.ConsumerSecret),
AccessToken: getFirstNonEmpty(os.Getenv("EMUARIUS_TWITTER_ACCESS_TOKEN"), toml.Twitter.AccessToken),
AccessTokenSecret: getFirstNonEmpty(os.Getenv("EMUARIUS_TWITTER_ACCESS_TOKEN_SECRET"), toml.Twitter.AccessTokenSecret),
},
}
}
Expand All @@ -88,9 +88,9 @@ func main() {
}
defer db.Close()

anaconda.SetConsumerKey(cfg.TwitterConfig.ConsumerKey)
anaconda.SetConsumerSecret(cfg.TwitterConfig.ConsumerSecret)
api := anaconda.NewTwitterApi(cfg.TwitterConfig.AccessToken, cfg.TwitterConfig.AccessTokenSecret)
anaconda.SetConsumerKey(cfg.Twitter.ConsumerKey)
anaconda.SetConsumerSecret(cfg.Twitter.ConsumerSecret)
api := anaconda.NewTwitterApi(cfg.Twitter.AccessToken, cfg.Twitter.AccessTokenSecret)

be := emuarius.NewBackend(api, db, cfg.RootURL)
h := ostatus.NewHandler(be, emuarius.HostMeta(cfg.RootURL))
Expand Down

0 comments on commit 6bf6db8

Please sign in to comment.