Make the linter happy
Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
parent
ab5abcd171
commit
7c2c1032cb
3 changed files with 9 additions and 10 deletions
9
api.go
9
api.go
|
@ -110,9 +110,9 @@ func (h *productsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
log.Warnf("cannot parse available query to boolean: %s", err)
|
log.Warnf("cannot parse available query to boolean: %s", err)
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
} else {
|
|
||||||
trx = h.db.Preload("Shop").Where(map[string]interface{}{"available": available}).Find(&products)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trx = h.db.Preload("Shop").Where(map[string]interface{}{"available": available}).Find(&products)
|
||||||
} else {
|
} else {
|
||||||
trx = h.db.Preload("Shop").Find(&products)
|
trx = h.db.Preload("Shop").Find(&products)
|
||||||
}
|
}
|
||||||
|
@ -147,7 +147,7 @@ func (h *productHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// StartAPI to handle HTTP requests
|
// StartAPI to handle HTTP requests
|
||||||
func StartAPI(db *gorm.DB, config ApiConfig) error {
|
func StartAPI(db *gorm.DB, config APIConfig) error {
|
||||||
router := mux.NewRouter().StrictSlash(true)
|
router := mux.NewRouter().StrictSlash(true)
|
||||||
|
|
||||||
router.Path("/health").HandlerFunc(handleHealth)
|
router.Path("/health").HandlerFunc(handleHealth)
|
||||||
|
@ -164,7 +164,6 @@ func StartAPI(db *gorm.DB, config ApiConfig) error {
|
||||||
log.Printf("starting API on %s", config.Address)
|
log.Printf("starting API on %s", config.Address)
|
||||||
if config.Certfile != "" && config.Keyfile != "" {
|
if config.Certfile != "" && config.Keyfile != "" {
|
||||||
return http.ListenAndServeTLS(config.Address, config.Certfile, config.Keyfile, router)
|
return http.ListenAndServeTLS(config.Address, config.Certfile, config.Keyfile, router)
|
||||||
} else {
|
|
||||||
return http.ListenAndServe(config.Address, router)
|
|
||||||
}
|
}
|
||||||
|
return http.ListenAndServe(config.Address, router)
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
type Config struct {
|
type Config struct {
|
||||||
TwitterConfig `json:"twitter"`
|
TwitterConfig `json:"twitter"`
|
||||||
TelegramConfig `json:"telegram"`
|
TelegramConfig `json:"telegram"`
|
||||||
ApiConfig `json:"api"`
|
APIConfig `json:"api"`
|
||||||
AmazonConfig `json:"amazon"`
|
AmazonConfig `json:"amazon"`
|
||||||
URLs []string `json:"urls"`
|
URLs []string `json:"urls"`
|
||||||
IncludeRegex string `json:"include_regex"`
|
IncludeRegex string `json:"include_regex"`
|
||||||
|
@ -36,8 +36,8 @@ type TelegramConfig struct {
|
||||||
EnableReplies bool `json:"enable_replies"`
|
EnableReplies bool `json:"enable_replies"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ApiConfig to store HTTP API configuration
|
// APIConfig to store HTTP API configuration
|
||||||
type ApiConfig struct {
|
type APIConfig struct {
|
||||||
Address string `json:"address"`
|
Address string `json:"address"`
|
||||||
Certfile string `json:"cert_file"`
|
Certfile string `json:"cert_file"`
|
||||||
Keyfile string `json:"key_file"`
|
Keyfile string `json:"key_file"`
|
||||||
|
@ -91,7 +91,7 @@ func (c *Config) HasTelegram() bool {
|
||||||
return c.TelegramConfig.Token != "" && (c.TelegramConfig.ChatID != 0 || c.TelegramConfig.ChannelName != "")
|
return c.TelegramConfig.Token != "" && (c.TelegramConfig.ChatID != 0 || c.TelegramConfig.ChannelName != "")
|
||||||
}
|
}
|
||||||
|
|
||||||
// HasURL returns true when list of URLS has been configured
|
// HasURLs returns true when list of URLS has been configured
|
||||||
func (c *Config) HasURLs() bool {
|
func (c *Config) HasURLs() bool {
|
||||||
return len(c.URLs) > 0
|
return len(c.URLs) > 0
|
||||||
}
|
}
|
||||||
|
|
2
main.go
2
main.go
|
@ -117,7 +117,7 @@ func main() {
|
||||||
|
|
||||||
// start the api
|
// start the api
|
||||||
if *api {
|
if *api {
|
||||||
log.Fatal(StartAPI(db, config.ApiConfig))
|
log.Fatal(StartAPI(db, config.APIConfig))
|
||||||
}
|
}
|
||||||
|
|
||||||
// register notifiers
|
// register notifiers
|
||||||
|
|
Reference in a new issue