If I'm using http.ListenAndServe
to provide responses when the user hits a URL, should I be firing off the corresponding actions in the function as a goroutine ?
For instance, say I'm listening at /
:
func main() {
http.HandleFunc("/", provideMainContent)
}
func provideMainContent(w http.ResponseWriter, r *http.Request) {
/// Bunch of code, looks up details in databases, parses, then returns
}
Should the bunch of code in provideMainContent
be wrapped in a goroutine so it doesn't slow down any potential requests that come after the fact ?