go http 请求参数获取
//获取url parames request.ParseForm() values := request.Form["firs"][0] //获取头部参数 request.Header.Get("name") //解决post body 第二次读为空问题 func handleIterceptor(h http.HandlerFunc) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { fmt.Println("handleIterceptor") buff, _ := ioutil.ReadAll(r.Body) r.Body.Close()//必须关闭后在给body 赋值 r.Body = ioutil.NopCloser(bytes.NewBuffer(buff)) fmt.Println(string(buff)) fmt.Printf("interceptor header %s\n",r.Header.Get("name")) h(w, r) } }
 
                     
                    
                 
                    
                
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号