What is the right way to shutdown the web-server that comes with the Go SDK?
Here's an example web service:
package main
import (
"fmt"
"net/http"
)
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hi there, I love %s!", r.URL.Path[1:])
}
func main() {
http.HandleFunc("/", handler)
http.ListenAndServe(":8080", nil)
}
That was pulled form here: https://golang.org/doc/articles/wiki/#tmp_3
However, I'd like to tear down this server and have it drain off any currently running requests. How is this done?