perf: precompiling proxy script callbacks

This commit is contained in:
evilsocket 2018-01-08 01:19:30 +01:00
parent 8f22e4a30c
commit b0ee042229
3 changed files with 88 additions and 62 deletions

View file

@ -1,5 +1,10 @@
package session_modules
import (
"fmt"
"net/http"
)
type JSHeader struct {
Name string
Value string
@ -14,6 +19,23 @@ type JSRequest struct {
Body string
}
func NewJSRequest(req *http.Request) JSRequest {
headers := make([]JSHeader, 0)
for key, values := range req.Header {
for _, value := range values {
headers = append(headers, JSHeader{key, value})
}
}
return JSRequest{
Method: req.Method,
Version: fmt.Sprintf("%d.%d", req.ProtoMajor, req.ProtoMinor),
Path: req.URL.Path,
Hostname: req.Host,
Headers: headers,
}
}
func (j *JSRequest) ReadBody() string {
return "TODO: read body"
}