[{"data":1,"prerenderedAt":67},["Reactive",2],{"/samples/go/go-resty":3,"related:p915YL7WJi":61},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"language":10,"library":11,"link":12,"body":13,"_type":56,"_id":57,"_source":58,"_file":59,"_extension":60},"/samples/go/go-resty","go",false,"","Go Resty","Go-Resty is a third-party HTTP client library for GoLang. It provides an easy-to-use API for making HTTP requests and handling responses, similar to libraries like net/http. Go-Resty simplifies tasks such as setting headers, handling cookies, and managing request parameters.","Go","go-resty","https://github.com/go-resty/resty",{"type":14,"children":15,"toc":53},"root",[16,32,44],{"type":17,"tag":18,"props":19,"children":20},"element","p",{},[21,30],{"type":17,"tag":22,"props":23,"children":26},"a",{"href":12,"rel":24},[25],"nofollow",[27],{"type":28,"value":29},"text","Go-Resty",{"type":28,"value":31}," is a third-party HTTP client library for GoLang. It provides an easy-to-use API for making HTTP requests and handling responses, similar to libraries like net/http. Go-Resty simplifies tasks such as setting headers, handling cookies, and managing request parameters.",{"type":17,"tag":33,"props":34,"children":38},"pre",{"className":35,"code":37,"language":5,"meta":7},[36],"language-go","package main\n\nimport (\n    \"encoding/json\"\n    \"fmt\"\n    \"github.com/go-resty/resty/v2\"\n    \"io/ioutil\"\n)\n\n// Convert function makes a POST request to the provided endpoint with the supplied parameters\nfunc convert(apiKey string, params map[string]string, endpoint string) ([]byte, error) {\n    client := resty.New()\n\n    // Perform the request\n    resp, err := client.R().\n        SetHeader(\"X-API-Key\", apiKey).\n        SetHeader(\"Content-Type\", \"application/json\").\n        SetBody(params).\n        Post(fmt.Sprintf(\"https://api.pdfshift.io/v3/convert/%s\", endpoint))\n\n    if err != nil {\n        return nil, err\n    }\n\n    if _, ok := params[\"filename\"]; ok || params[\"webhook\"]; ok {\n        var response map[string]interface{}\n        err := json.Unmarshal(resp.Body(), &response)\n        if err != nil {\n            return nil, err\n        }\n        return json.Marshal(response)\n    }\n\n    return resp.Body(), nil\n}\n",[39],{"type":17,"tag":40,"props":41,"children":42},"code",{"__ignoreMap":7},[43],{"type":28,"value":37},{"type":17,"tag":33,"props":45,"children":48},{"className":46,"code":47,"language":5,"meta":7},[36],"func main() {\n    params := map[string]string{\"source\": \"https://en.wikipedia.org/wiki/REST\"}\n    apiKey := \"sk_XXXXXXXXXXXXXX\"\n\n    resp, err := convert(apiKey, params, \"pdf\")\n    if err != nil {\n        panic(err)\n    }\n\n    error := ioutil.WriteFile(\"result.pdf\", resp, 0644)\n    if error != nil {\n        panic(err)\n    }\n}\n",[49],{"type":17,"tag":40,"props":50,"children":51},{"__ignoreMap":7},[52],{"type":28,"value":47},{"title":7,"searchDepth":54,"depth":54,"links":55},2,[],"markdown","content:samples:go:go-resty.md","content","samples/go/go-resty.md","md",[62,63],{"_path":4,"language":10,"library":11,"_id":57},{"_path":64,"language":10,"library":65,"_id":66},"/samples/go/nethttp","Net/HTTP","content:samples:go:nethttp.md",1785426823204]