Adding .gitignore and fixes (return) for logic.

master
Tomasz Półgrabia 2022-01-15 19:20:10 +01:00
parent 6890c87586
commit b8eaa40100
2 changed files with 5 additions and 0 deletions

2
2022/01/golang_demo2/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.idea
*.iml

View File

@ -26,6 +26,7 @@ func handleIndex(writer http.ResponseWriter, _ *http.Request) {
writer.WriteHeader(500) writer.WriteHeader(500)
_, _ = writer.Write([]byte("Internal server error")) _, _ = writer.Write([]byte("Internal server error"))
_, _ = fmt.Fprintf(os.Stderr, "Internal server error while marshalling response") _, _ = fmt.Fprintf(os.Stderr, "Internal server error while marshalling response")
return
} }
writer.Header().Set("Content-Type", "application/json") writer.Header().Set("Content-Type", "application/json")
@ -51,6 +52,7 @@ func handleInfo(writer http.ResponseWriter, _ *http.Request) {
writer.WriteHeader(500) writer.WriteHeader(500)
_, _ = writer.Write([]byte("Internal server error")) _, _ = writer.Write([]byte("Internal server error"))
_, _ = fmt.Fprintf(os.Stderr, "Internal server error while marshalling response") _, _ = fmt.Fprintf(os.Stderr, "Internal server error while marshalling response")
return
} }
writer.Header().Set("Content-Type", "application/json") writer.Header().Set("Content-Type", "application/json")
@ -77,6 +79,7 @@ func handleDefault(writer http.ResponseWriter, _ *http.Request) {
writer.WriteHeader(500) writer.WriteHeader(500)
_, _ = writer.Write([]byte("Internal server error")) _, _ = writer.Write([]byte("Internal server error"))
_, _ = fmt.Fprintf(os.Stderr, "Internal server error while marshalling response") _, _ = fmt.Fprintf(os.Stderr, "Internal server error while marshalling response")
return
} }
writer.Header().Set("Content-Type", "application/json") writer.Header().Set("Content-Type", "application/json")