gobuch/microservices/rfc7808/client/main.go

27 lines
473 B
Go
Raw Normal View History

2020-08-21 04:26:40 +00:00
package main
import (
"encoding/json"
"io/ioutil"
"log"
"net/http"
"github.com/moogar0880/problems"
)
func main() {
res, err := http.Get("http://localhost:8080/a")
if err != nil {
log.Fatal("could not request")
}
defer res.Body.Close()
if res.StatusCode != http.StatusOK {
problem := &problems.DefaultProblem{}
bites, _ := ioutil.ReadAll(res.Body)
json.Unmarshal(bites, problem)
log.Println(problem.ProblemTitle())
} else {
log.Println("ok")
}
}