initial import

This commit is contained in:
SourceFellows
2020-08-21 06:26:40 +02:00
commit e223458dd4
423 changed files with 9871 additions and 0 deletions

View File

@ -0,0 +1,5 @@
module golang.source-fellows.com/samples/rfc7808/server
go 1.13
require github.com/moogar0880/problems v0.1.1

View 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=

View 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")
}
}