From e1a1f1c0f0b9d879f368ce1da289443831d0a4d0 Mon Sep 17 00:00:00 2001 From: Asim Aslam Date: Wed, 31 May 2017 19:47:50 +0100 Subject: [PATCH] add wait option --- server/options.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/server/options.go b/server/options.go index edaeceea..c4602498 100644 --- a/server/options.go +++ b/server/options.go @@ -165,6 +165,16 @@ func RegisterTTL(t time.Duration) Option { } } +// Wait tells the server to wait for requests to finish before exiting +func Wait(b bool) Option { + return func(o *Options) { + if o.Context == nil { + o.Context = context.Background() + } + o.Context = context.WithValue(o.Context, "wait", b) + } +} + // Adds a handler Wrapper to a list of options passed into the server func WrapHandler(w HandlerWrapper) Option { return func(o *Options) {