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 // indirect

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,22 @@
package main
import (
"encoding/json"
"net/http"
"github.com/moogar0880/problems"
)
func handleHttp(res http.ResponseWriter, req *http.Request) {
NotFound := problems.NewStatusProblem(http.StatusNotFound)
bites, _ := json.Marshal(NotFound)
res.WriteHeader(http.StatusNotFound)
res.Header().Add("Content-Type", "application/json")
res.Write(bites)
}
func main() {
http.HandleFunc("/a/", handleHttp)
http.ListenAndServe(":8080", nil)
}