Maybe this is a silly question but I'm trying to use this and I'm having trouble setting the request headers.
I used the example in the readme:
import "github.com/yuin/gopher-lua"
import "github.com/cjoudrey/gluahttp"
func main() {
L := lua.NewState()
defer L.Close()
L.PreloadModule("http", NewHttpModule(&http.Client{}).Loader)
if err := L.DoString(`
local http = require("http")
response, error_message = http.request("GET", "http://example.com", {
query="page=1",
timeout="30s",
headers={
Accept="*/*",
Content-Type="application/json", // THIS DOES NOT WORK?
}
})
`); err != nil {
panic(err)
}
}
The headers that are passed in are of type table. But for a tables field name I can't use the - character. For http header like Content-Type this character is necessary. Is there a way to work around this.
Maybe this is a silly question but I'm trying to use this and I'm having trouble setting the request headers.
I used the example in the readme:
The headers that are passed in are of type table. But for a tables field name I can't use the
-
character. For http header likeContent-Type
this character is necessary. Is there a way to work around this.