Add timeout to requests

This commit is contained in:
2020-10-11 17:55:27 -06:00
parent 6c885d25c2
commit b7c7c2bf23
3 changed files with 24 additions and 15 deletions

View File

@ -4,6 +4,7 @@ import (
"flag"
"log"
"net/http"
"time"
"gitlab.codemonkeysoftware.net/b/henwen/internal/back"
"gitlab.codemonkeysoftware.net/b/henwen/internal/front"
@ -14,6 +15,7 @@ func main() {
title := flag.String("title", "Henwen", "website title")
baseURL := flag.String("baseURL", "http://localhost:8080", "base URL for HTTP routes")
dbFileName := flag.String("db", "./henwen.db", "name of database file")
httpTimeout := flag.Int("httpTimeout", 5000, "HTTP server timeout in ms")
flag.Parse()
store, err := back.NewStore(*dbFileName, back.SecureGenString)
@ -27,6 +29,7 @@ func main() {
Store: store,
Title: *title,
BaseURL: *baseURL,
Timeout: time.Millisecond * time.Duration(*httpTimeout),
}),
}