Created
July 26, 2020 18:29
-
-
Save IgorDePaula/f4e479dfeb013690b2ffac1af30d6367 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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