Skip to content

Instantly share code, notes, and snippets.

@IgorDePaula
Created July 26, 2020 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IgorDePaula/f4e479dfeb013690b2ffac1af30d6367 to your computer and use it in GitHub Desktop.
Save IgorDePaula/f4e479dfeb013690b2ffac1af30d6367 to your computer and use it in GitHub Desktop.
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
)
func main() {
requestBody, err := json.Marshal(map[string]string{
"name": "igor",
"email": "igordepaula@adminweb.com.br",
})
if err != nil {
log.Fatalln(err)
}
resp, err := http.Post("http://localhost:8001/api/go","application/json", bytes.NewBuffer(requestBody))
if err != nil {
log.Fatalln(err)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatalln(err)
}
log.Println(body)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment