Skip to content

Instantly share code, notes, and snippets.

@itwars
Created March 9, 2018 14:45
Show Gist options
  • Save itwars/d42b5cede332ca8d49aa64845d3d6b1c to your computer and use it in GitHub Desktop.
Save itwars/d42b5cede332ca8d49aa64845d3d6b1c to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://reqres.in/api/users"
payload := strings.NewReader("name=test&jab=teacher")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/x-www-form-urlencoded")
req.Header.Add("cache-control", "no-cache")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(string(body))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment