For simple things, you can fire up a goroutine to do the "something else" after the request finishes. For example, I've used this before to kick off sending an email to a customer in the background (you'll want to handle/report errors somehow though):
package main
import (
"fmt"
"log"
"net/http"
"time"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, "sending email in the background")
go sendEmail()
// response is sent, but sendEmail goroutine continues
})
log.Print("listening on
http://localhost:8080")
http.ListenAndServe(":8080", nil)
}
func sendEmail() {
log.Printf("would send an email here")
time.Sleep(time.Second)
log.Printf("done sending email")
}