package main
import ( "log" "net/http" )
func main() { http.HandleFunc("/", handler) http.ListenAndServe(":8081", nil) }
func handler(w http.ResponseWriter, r *http.Request) {
keys, ok := r.URL.Query()["key"]
if !ok || len(keys) < 1 {
log.Println("Url Param 'key' is missing")
return
}
// Query()["key"] will return an array of items,
// we only want the single item.
key := keys[0]
log.Println("Url Param 'key' is: " + string(key))
}
转载于:https://www.cnblogs.com/Dennis-mi/p/8495175.html