http://localhost:8080/param?hhh=aaa
例如像这样的网址,获取请求头和请求参数
package main
import (
"fmt"
"net/http"
)
func param(w http.ResponseWriter, r *http.Request) {
h := r.Header//这个是请求头信息
fmt.Fprintln(w, h)//打印请求头
fmt.Fprintln(w, r.FormValue("hhh"))//打印请求参数
}
func main() {
server := http.Server{Addr: "localhost:8080"}
http.HandleFunc("/param", param)
server.ListenAndServe()
}