Archived
1
0
Fork 0

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:
Julien Riou 2021-03-25 18:00:29 +01:00
parent 3122e59325
commit 17a88265c6
No known key found for this signature in database
GPG key ID: FF42D23B580C89F7
7 changed files with 200 additions and 3 deletions

View file

@ -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{}