I design a new Request structure, but in some scenarios(http.Redirect), I need to get the origin http.Request
.
My Request struct:
type Request struct {
*http.Request
}
func (r *Request) IsGet() bool {
return strings.EqualFold("GET", r.Method)
}
Main function:
req := http.Request{
Method:"POST",
}
myReq := &Request{&req}
// How to get original request.
originalReq, ok := (interface{}(*myReq)).(http.Request);
if ok {
fmt.Printf("Method: %s
", originalReq.Method)
} else {
fmt.Println("Failure")
}