This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
packageflow
import(
"encoding/json"
"net/http"
"net/url"
_log"github.com/sirupsen/logrus"
)
varlog=_log.WithField("at","flow")
typeRequeststruct{
Methodstring
URL*url.URL
Protostring
Headerhttp.Header
Body[]byte
raw*http.Request
}
func(req*Request)MarshalJSON()([]byte,error){
r:=make(map[string]interface{})
r["method"]=req.Method
r["url"]=req.URL.String()
r["proto"]=req.Proto
r["header"]=req.Header
r["body"]=req.Body
returnjson.Marshal(r)
}
funcNewRequest(req*http.Request)*Request{
return&Request{
Method:req.Method,
URL:req.URL,
Proto:req.Proto,
Header:req.Header,
raw:req,
}
}
func(r*Request)Raw()*http.Request{
returnr.raw
}
typeResponsestruct{
StatusCodeint`json:"statusCode"`
Headerhttp.Header`json:"header"`
Body[]byte`json:"body"`
decodedBody[]byte
decodedbool// decoded reports whether the response was sent compressed but was decoded to decodedBody.