Created
March 16, 2019 09:58
-
-
Save brpaz/cb02df75cd3167f752c41ca1776012bb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
func main() { | |
u := User{Id: "US123", Balance: 8} | |
b := new(bytes.Buffer) | |
json.NewEncoder(b).Encode(u) | |
res, _ := http.Post("https://httpbin.org/post", "application/json; charset=utf-8", b) | |
var body struct { | |
// httpbin.org sends back key/value pairs, no map[string][]string | |
Headers map[string]string `json:"headers"` | |
Origin string `json:"origin"` | |
} | |
json.NewDecoder(res.Body).Decode(&body) | |
fmt.Println(body) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment