Reduce cyclometric complexity
This commit is contained in:
parent
d8a5acd2e2
commit
8e001408d8
1 changed files with 13 additions and 9 deletions
22
main.go
22
main.go
|
@ -135,15 +135,8 @@ func main() {
|
|||
if len(cfg.EmailAddresses) > 0 && cfg.SMTPServer == "" {
|
||||
log.Fatal("Email address(es) specified but no smtp_server configured. Wrong configuration, aborting...")
|
||||
}
|
||||
var genericWebhookClient *http.Client
|
||||
if cfg.GenericWebhookURL == "" {
|
||||
fmt.Println("No generic_webhook_url configured.")
|
||||
} else {
|
||||
fmt.Println("Will forward metadata of all requests to ", cfg.GenericWebhookURL)
|
||||
genericWebhookClient = &http.Client{
|
||||
Timeout: time.Second * 300,
|
||||
}
|
||||
}
|
||||
|
||||
genericWebhookClient := configureGenericWebhookClient(cfg)
|
||||
|
||||
apiPrefix := cfg.APIPrefix
|
||||
if apiPrefix == "" {
|
||||
|
@ -187,6 +180,17 @@ func main() {
|
|||
log.Fatal(http.ListenAndServe(*bindAddr, nil))
|
||||
}
|
||||
|
||||
func configureGenericWebhookClient(cfg *config) (*http.Client) {
|
||||
if cfg.GenericWebhookURL == "" {
|
||||
fmt.Println("No generic_webhook_url configured.")
|
||||
return nil
|
||||
}
|
||||
fmt.Println("Will forward metadata of all requests to ", cfg.GenericWebhookURL)
|
||||
return &http.Client{
|
||||
Timeout: time.Second * 300,
|
||||
}
|
||||
}
|
||||
|
||||
func loadConfig(configPath string) (*config, error) {
|
||||
contents, err := ioutil.ReadFile(configPath)
|
||||
if err != nil {
|
||||
|
|
Reference in a new issue