Skip to content

Instantly share code, notes, and snippets.

@fwojciec
Created July 23, 2018 06:53
Show Gist options
  • Save fwojciec/7be15936d8b044364b27dbeca47c2510 to your computer and use it in GitHub Desktop.
Save fwojciec/7be15936d8b044364b27dbeca47c2510 to your computer and use it in GitHub Desktop.
My solution to "Exercise PUT request" from Section 01 of Francesc Campoy's Go Web Workshop
// https://github.com/campoy/go-web-workshop/blob/master/section01/README.md
package main
import (
"fmt"
"log"
"net/http"
"strings"
)
func main() {
body := strings.NewReader("one who loves horses")
req, err := http.NewRequest("PUT", "https://http-methods.appspot.com/filip/Message", body)
if err != nil {
log.Fatalf("could not create request: %v", err)
}
client := http.DefaultClient
res, err := client.Do(req)
if err != nil {
log.Fatalf("http request failed: %v", err)
}
fmt.Println(res.Status)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment