github.com/versent/saml2aws@v2.17.0+incompatible/pkg/dump/dump.go (about) 1 package dump 2 3 import ( 4 "net/http" 5 "net/http/httputil" 6 "os" 7 ) 8 9 // RequestString helper method to dump the http request 10 func RequestString(req *http.Request) string { 11 data, err := httputil.DumpRequestOut(req, ContentEnable()) 12 13 if err != nil { 14 return "" 15 } 16 17 return string(data) 18 } 19 20 // ResponseString helper method to dump the http response 21 func ResponseString(res *http.Response) string { 22 data, err := httputil.DumpResponse(res, ContentEnable()) 23 24 if err != nil { 25 return "" 26 } 27 28 return string(data) 29 } 30 31 // ContentEnable enable dumping of request / response content 32 func ContentEnable() bool { 33 return os.Getenv("DUMP_CONTENT") == "true" 34 }