Skip to content

Instantly share code, notes, and snippets.

@antklim
Last active November 23, 2020 06:40
Show Gist options
  • Save antklim/4fc9140f02ac8aba42b6a36fab8ac456 to your computer and use it in GitHub Desktop.
Save antklim/4fc9140f02ac8aba42b6a36fab8ac456 to your computer and use it in GitHub Desktop.
func Start(address string, routes map[string]http.HandlerFunc) error {
mux := http.NewServeMux()
for route, handler := range routes {
mux.Handle(route, handler)
}
s := &http.Server{
Addr: address,
Handler: mux,
ReadTimeout: 10 * time.Second,
WriteTimeout: 10 * time.Second,
MaxHeaderBytes: 1 << 20,
}
return s.ListenAndServe()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment