diff options
author | =Corey Hulen <corey@hulen.com> | 2015-11-23 15:53:48 -0800 |
---|---|---|
committer | =Corey Hulen <corey@hulen.com> | 2015-11-23 15:53:48 -0800 |
commit | 4f4cd5e63573da4d6edcc7d4213afaca67c19f88 (patch) | |
tree | cefbc7af53629d97644ca2f6b2369e9d879f0101 /Godeps/_workspace/src/github.com/braintree/manners/static.go | |
parent | f8a3c9a14edca6df0647d89cf225f2470cbe025c (diff) | |
download | chat-4f4cd5e63573da4d6edcc7d4213afaca67c19f88.tar.gz chat-4f4cd5e63573da4d6edcc7d4213afaca67c19f88.tar.bz2 chat-4f4cd5e63573da4d6edcc7d4213afaca67c19f88.zip |
upgrading libs
Diffstat (limited to 'Godeps/_workspace/src/github.com/braintree/manners/static.go')
-rw-r--r-- | Godeps/_workspace/src/github.com/braintree/manners/static.go | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/Godeps/_workspace/src/github.com/braintree/manners/static.go b/Godeps/_workspace/src/github.com/braintree/manners/static.go new file mode 100644 index 000000000..2a74b094b --- /dev/null +++ b/Godeps/_workspace/src/github.com/braintree/manners/static.go @@ -0,0 +1,35 @@ +package manners + +import ( + "net" + "net/http" +) + +var defaultServer *GracefulServer + +// ListenAndServe provides a graceful version of the function provided by the +// net/http package. Call Close() to stop the server. +func ListenAndServe(addr string, handler http.Handler) error { + defaultServer = NewWithServer(&http.Server{Addr: addr, Handler: handler}) + return defaultServer.ListenAndServe() +} + +// ListenAndServeTLS provides a graceful version of the function provided by the +// net/http package. Call Close() to stop the server. +func ListenAndServeTLS(addr string, certFile string, keyFile string, handler http.Handler) error { + defaultServer = NewWithServer(&http.Server{Addr: addr, Handler: handler}) + return defaultServer.ListenAndServeTLS(certFile, keyFile) +} + +// Serve provides a graceful version of the function provided by the net/http +// package. Call Close() to stop the server. +func Serve(l net.Listener, handler http.Handler) error { + defaultServer = NewWithServer(&http.Server{Handler: handler}) + return defaultServer.Serve(l) +} + +// Shuts down the default server used by ListenAndServe, ListenAndServeTLS and +// Serve. It returns true if it's the first time Close is called. +func Close() bool { + return defaultServer.Close() +} |