Documentation ¶
Index ¶
Examples ¶
Constants ¶
View Source
const ( // default http User Agent DefaultUserAgent = `gopher-lua` // default http timeout DefaultTimeout = 10 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func DoRequest ¶
DoRequest lua http_client_ud:do_request() http_client_ud:do_request(http_request_ud) returns (response, error)
response: { code = http_code (200, 201, ..., 500, ...), body = string headers = table }
Example ¶
http_client_ud:do_request(request)
package main import ( "log" http "github.com/metafates/mangal-lua-libs/http" lua "github.com/yuin/gopher-lua" ) func main() { state := lua.NewState() http.Preload(state) source := ` local http = require("http") local client = http.client() local request = http.request("GET", "https://google.com") local result, err = client:do_request(request) if err then error(err) end print(result.code) ` if err := state.DoString(source); err != nil { log.Fatal(err.Error()) } }
Output: 200
func New ¶
http.client(config) returns (user data, error) config table:
{ proxy="http(s)://<user>:<password>@host:<port>", timeout= 10, insecure_ssl=false, user_agent = "gopher-lua", basic_auth_user = "", basic_auth_password = "", headers = {"key"="value"}, debug = false, }
func NewFileRequest ¶
http.filerequest(url, files, params) returns user-data, error
func NewRequest ¶
http.request(verb, url, body) returns user-data, error
Types ¶
Click to show internal directories.
Click to hide internal directories.