This commit is contained in:
Nicolas Lepage 2021-01-27 23:06:28 +01:00
parent 04f6573b78
commit 896b5a3cee
No known key found for this signature in database
GPG Key ID: B0879E35E66D8F6F
2 changed files with 3 additions and 8 deletions

View File

@ -8,7 +8,7 @@ import (
)
// Request builds and returns the equivalent http.Request
func Request(r js.Value) (*http.Request, error) {
func Request(r js.Value) *http.Request {
jsBody := js.Global().Get("Uint8Array").New(Promise{r.Call("arrayBuffer")}.Await())
body := make([]byte, jsBody.Get("length").Int())
js.CopyBytesToGo(body, jsBody)
@ -29,5 +29,5 @@ func Request(r js.Value) (*http.Request, error) {
req.Header.Set(v.Index(0).String(), v.Index(1).String())
}
return req, nil
return req
}

View File

@ -38,14 +38,9 @@ func Serve(handler http.Handler) func() {
}
}()
var req, err = Request(args[0])
if err != nil {
panic(err)
}
var res = NewResponseRecorder()
h.ServeHTTP(res, req)
h.ServeHTTP(res, Request(args[0]))
resolve(res)
}()