mirror of
https://github.com/SourceFellows/gobuch.git
synced 2025-07-20 07:02:53 +02:00
initial import
This commit is contained in:
5
microservices/rfc7808/client/go.mod
Normal file
5
microservices/rfc7808/client/go.mod
Normal file
@ -0,0 +1,5 @@
|
||||
module golang.source-fellows.com/samples/rfc7808/server
|
||||
|
||||
go 1.13
|
||||
|
||||
require github.com/moogar0880/problems v0.1.1
|
2
microservices/rfc7808/client/go.sum
Normal file
2
microservices/rfc7808/client/go.sum
Normal file
@ -0,0 +1,2 @@
|
||||
github.com/moogar0880/problems v0.1.1 h1:bktLhq8NDG/czU2ZziYNigBFksx13RaYe5AVdNmHDT4=
|
||||
github.com/moogar0880/problems v0.1.1/go.mod h1:5Dxrk2sD7BfBAgnOzQ1yaTiuCYdGPUh49L8Vhfky62c=
|
26
microservices/rfc7808/client/main.go
Normal file
26
microservices/rfc7808/client/main.go
Normal file
@ -0,0 +1,26 @@
|
||||
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")
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user