go http request parameter acquiring

// Get Parames URL 
request.ParseForm () 
values: = request.Form [ "FIRs"] [0 ] 

// Get header parameters 
request.Header.Get ( "name" ) 


// solve the post body of the second read space at 

FUNC handleIterceptor (H http.HandlerFunc) http.HandlerFunc { 
    return FUNC (http.ResponseWriter W, R & lt * http.Request) { 
        fmt.Println ( "handleIterceptor" )
         BUFF, _: = ioutil.ReadAll (r.Body) 
        r.Body.Close () // must be closed to the body in the assignment 
        r.Body = ioutil.NopCloser (bytes.NewBuffer (BUFF)) 
        fmt.Println (String (BUFF)) 
        fmt.Printf ("interceptor header %s\n",r.Header.Get("name"))
        h(w, r)
    }
}

 

Guess you like

Origin www.cnblogs.com/libing029/p/12483760.html