mirror of
https://github.com/sony/sonyflake.git
synced 2026-11-22 08:06:28 +00:00
Add error checks
This commit is contained in:
1 parent
bdd4a37407
commit
f7d8fbd6eb
1 file changed
+9
-2
@@ -33,10 +33,17 @@ func handler(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
w.Header()["Content-Type"] = []string{"application/json; charset=utf-8"}
|
w.Header()["Content-Type"] = []string{"application/json; charset=utf-8"}
|
||||||
w.Write(body)
|
_, err = w.Write(body)
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
http.HandleFunc("/", handler)
|
http.HandleFunc("/", handler)
|
||||||
http.ListenAndServe(":8080", nil)
|
err := http.ListenAndServe(":8080", nil)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user