Add HTTP API
Add `-api` mode to start the HTTP API with the following routes: - /health - /shops - /shops/:id - /products - /products/:id Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
parent
3122e59325
commit
17a88265c6
7 changed files with 200 additions and 3 deletions
6
main.go
6
main.go
|
@ -52,6 +52,7 @@ func main() {
|
|||
workers := flag.Int("workers", 1, "number of workers for parsing shops")
|
||||
pidFile := flag.String("pid-file", "", "write process ID to this file to disable concurrent executions")
|
||||
pidWaitTimeout := flag.Int("pid-wait-timeout", 0, "seconds to wait before giving up when another instance is running")
|
||||
api := flag.Bool("api", false, "Start the HTTP API")
|
||||
|
||||
flag.Parse()
|
||||
|
||||
|
@ -114,6 +115,11 @@ func main() {
|
|||
log.Fatalf("cannot create shops table")
|
||||
}
|
||||
|
||||
// start the api
|
||||
if *api {
|
||||
log.Fatal(StartAPI(db, config.ApiConfig))
|
||||
}
|
||||
|
||||
// register notifiers
|
||||
notifiers := []Notifier{}
|
||||
|
||||
|
|
Reference in a new issue