diff --git a/context.go b/context.go index cd91dea..4819544 100644 --- a/context.go +++ b/context.go @@ -91,6 +91,8 @@ type ( } ) +var _ http.ResponseWriter = (*Context)(nil) + var ( errSignKeyIsNil = hes.New("keys for sign cookie can't be nil") ) diff --git a/elton.go b/elton.go index 9b5948c..d03a1ec 100644 --- a/elton.go +++ b/elton.go @@ -23,6 +23,7 @@ package elton import ( + "context" "errors" "fmt" "io" @@ -207,13 +208,18 @@ func (e *Elton) Close() error { return e.Server.Close() } +// Shutdown shotdown the http server +func (e *Elton) Shutdown() error { + return e.Server.Shutdown(context.Background()) +} + // GracefulClose graceful close the http server. // It sets the status to be closing and delay to close. func (e *Elton) GracefulClose(delay time.Duration) error { atomic.StoreInt32(&e.status, StatusClosing) time.Sleep(delay) atomic.StoreInt32(&e.status, StatusClosed) - return e.Close() + return e.Shutdown() } // GetStatus get status of elton diff --git a/go.mod b/go.mod index 057c0c5..3d5709f 100644 --- a/go.mod +++ b/go.mod @@ -4,9 +4,9 @@ go 1.12 require ( github.com/stretchr/testify v1.6.1 - github.com/tidwall/gjson v1.6.4 + github.com/tidwall/gjson v1.6.7 github.com/vicanso/fresh v1.0.0 - github.com/vicanso/hes v0.2.4 + github.com/vicanso/hes v0.3.0 github.com/vicanso/intranet-ip v0.0.1 github.com/vicanso/keygrip v1.1.0 ) diff --git a/go.sum b/go.sum index 402e603..0d0b80e 100644 --- a/go.sum +++ b/go.sum @@ -2,6 +2,7 @@ github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -9,14 +10,20 @@ github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/tidwall/gjson v1.6.4 h1:JKsCsJqRVFz8eYCsQ5E/ANRbK6CanAtA9IUvGsXklyo= github.com/tidwall/gjson v1.6.4/go.mod h1:BaHyNc5bjzYkPqgLq7mdVzeiRtULKULXLgZFKsxEHI0= +github.com/tidwall/gjson v1.6.7 h1:Mb1M9HZCRWEcXQ8ieJo7auYyyiSux6w9XN3AdTpxJrE= +github.com/tidwall/gjson v1.6.7/go.mod h1:zeFuBCIqD4sN/gmqBzZ4j7Jd6UcA2Fc56x7QFsv+8fI= github.com/tidwall/match v1.0.1 h1:PnKP62LPNxHKTwvHHZZzdOAOCtsJTjo6dZLCwpKm5xc= github.com/tidwall/match v1.0.1/go.mod h1:LujAq0jyVjBy028G1WhWfIzbpQfMO8bBZ6Tyb0+pL9E= +github.com/tidwall/match v1.0.3 h1:FQUVvBImDutD8wJLN6c5eMzWtjgONK9MwIBCOrUJKeE= +github.com/tidwall/match v1.0.3/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= github.com/tidwall/pretty v1.0.2 h1:Z7S3cePv9Jwm1KwS0513MRaoUe3S01WPbLNV40pwWZU= github.com/tidwall/pretty v1.0.2/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/vicanso/fresh v1.0.0 h1:u3ykbW6SYW5CbI6rx1lZCVfWKVIptvL6/2KOnrTKsTY= github.com/vicanso/fresh v1.0.0/go.mod h1:gr1RKSFxQ1OnQHzUMBHCigifni7KrXveJjWCTlPjICA= github.com/vicanso/hes v0.2.4 h1:pm4129ydQhGVfUZUELNgn0H9zvi/K6iIe77yAVgeW7c= github.com/vicanso/hes v0.2.4/go.mod h1:QcxOFmFfBQMhASTaLgnFayXYCgevdSeBVprt+o+3eKo= +github.com/vicanso/hes v0.3.0 h1:atgM8+nBBdti7Ru0R84I7yh4fY4Yy9Ykq0K5EhMk77c= +github.com/vicanso/hes v0.3.0/go.mod h1:QcxOFmFfBQMhASTaLgnFayXYCgevdSeBVprt+o+3eKo= github.com/vicanso/intranet-ip v0.0.1 h1:cYS+mExFsKqewWSuHtFwAqw/CO66GsheB/P1BPmSTx0= github.com/vicanso/intranet-ip v0.0.1/go.mod h1:bqQ6VUhxdz0ipSb1kzd6aoZStlp+pB7CTlVmVhgLAxA= github.com/vicanso/keygrip v1.1.0 h1:B+qtNe/vvgZbYlkbJC4cOsbY9MzNp23+m2+ZybRy45Q=