// create a new GET request req := &Request{ Method: "GET", Url: "http://example.com", } // send the request resp, err := req.Send() if err != nil { log.Fatal(err) } // handle the response fmt.Println(resp)
// create a new POST request with JSON data and headers data := map[string]interface{}{ "name": "Alice", "email": "[email protected]", } headers := map[string]string{ "Content-Type": "application/json", } req := &Request{ Method: "POST", Url: "http://example.com/api/users", Headers: headers, Body: data, } // send the request resp, err := req.Send() if err != nil { log.Fatal(err) } // handle the response fmt.Println(resp)In this example, we create a new Request object with Method set to "POST", Url set to "http://example.com/api/users", Headers set to a map of headers, and Body set to a map of JSON data. We then call the Send method to send the request, and handle the response in the resp variable.