mirror of
https://github.com/bettercap/bettercap
synced 2025-07-13 00:23:49 -07:00
refact: returning pointers for both js request and js response
This commit is contained in:
parent
291b95b5f7
commit
cb58258bd7
3 changed files with 5 additions and 5 deletions
|
@ -27,7 +27,7 @@ type JSRequest struct {
|
||||||
req *http.Request
|
req *http.Request
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewJSRequest(req *http.Request) JSRequest {
|
func NewJSRequest(req *http.Request) *JSRequest {
|
||||||
headers := make([]JSHeader, 0)
|
headers := make([]JSHeader, 0)
|
||||||
cType := ""
|
cType := ""
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ func NewJSRequest(req *http.Request) JSRequest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return JSRequest{
|
return &JSRequest{
|
||||||
Client: strings.Split(req.RemoteAddr, ":")[0],
|
Client: strings.Split(req.RemoteAddr, ":")[0],
|
||||||
Method: req.Method,
|
Method: req.Method,
|
||||||
Version: fmt.Sprintf("%d.%d", req.ProtoMajor, req.ProtoMinor),
|
Version: fmt.Sprintf("%d.%d", req.ProtoMajor, req.ProtoMinor),
|
||||||
|
|
|
@ -63,7 +63,7 @@ func LoadHttpProxyScript(path string, sess *session.Session) (err error, s *Http
|
||||||
func (s *HttpProxyScript) doRequestDefines(req *http.Request) (err error, jsres *JSResponse) {
|
func (s *HttpProxyScript) doRequestDefines(req *http.Request) (err error, jsres *JSResponse) {
|
||||||
// convert request and define empty response to be optionally filled
|
// convert request and define empty response to be optionally filled
|
||||||
jsreq := NewJSRequest(req)
|
jsreq := NewJSRequest(req)
|
||||||
if err = s.VM.Set("req", &jsreq); err != nil {
|
if err = s.VM.Set("req", jsreq); err != nil {
|
||||||
log.Error("Error while defining request: %s", err)
|
log.Error("Error while defining request: %s", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue