add support for per-request timeout

Adds a -timeout flag for specifying the timeout.  Currently, this
returns a 503 response on timeout, though it should really be a 504,
since imageproxy is acting as a gateway.

Ref: #75
This commit is contained in:
Will Norris 2016-11-29 13:50:19 -08:00
parent 94dbd77d6e
commit 93166a5b20
2 changed files with 17 additions and 1 deletions

View file

@ -49,6 +49,7 @@ var cacheDir = flag.String("cacheDir", "", "(Deprecated; use 'cache' instead) di
var cacheSize = flag.Uint64("cacheSize", 0, "Deprecated: this flag does nothing")
var signatureKey = flag.String("signatureKey", "", "HMAC key used in calculating request signatures")
var scaleUp = flag.Bool("scaleUp", false, "allow images to scale beyond their original dimensions")
var timeout = flag.Duration("timeout", 0, "time limit for requests served by this proxy")
var version = flag.Bool("version", false, "print version information")
func main() {
@ -91,6 +92,7 @@ func main() {
}
}
p.Timeout = *timeout
p.ScaleUp = *scaleUp
server := &http.Server{