How to use regular expression matching URL, which does decide to use the corresponding function processing
package main
import(
"fmt"
"net/http"
)
func main() {
http.HandleFunc("/pattern", resolve)
http.ListenAndServe(":8080", nil)
}
func resolve(w http.ResponseWriter, r * http.Request) {
fmt.Println(r.URL.Host)
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…