Skip to content
Snippets Groups Projects
Verified Commit 6f9e6245 authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

fix: log requests and return status codes

parent 9c6eca4b
No related branches found
No related tags found
No related merge requests found
...@@ -72,9 +72,11 @@ func (bot *MatrixBot) HandleFunc(command string, handler func(bot *MatrixBot, no ...@@ -72,9 +72,11 @@ func (bot *MatrixBot) HandleFunc(command string, handler func(bot *MatrixBot, no
func (bot *MatrixBot) Serve(endpoint string) { func (bot *MatrixBot) Serve(endpoint string) {
http.HandleFunc("/healthz", func(writer http.ResponseWriter, request *http.Request) { http.HandleFunc("/healthz", func(writer http.ResponseWriter, request *http.Request) {
writer.WriteHeader(200)
_, _ = io.WriteString(writer, "OK\n") _, _ = io.WriteString(writer, "OK\n")
}) })
http.HandleFunc("/_matrix/push/v1/notify", func(writer http.ResponseWriter, request *http.Request) { http.HandleFunc("/_matrix/push/v1/notify", func(writer http.ResponseWriter, request *http.Request) {
log.Println("Received push notification")
notification, err := api.ParseNotification(request.Body) notification, err := api.ParseNotification(request.Body)
if err != nil { if err != nil {
log.Println(err.Error()) log.Println(err.Error())
...@@ -99,6 +101,7 @@ func (bot *MatrixBot) Serve(endpoint string) { ...@@ -99,6 +101,7 @@ func (bot *MatrixBot) Serve(endpoint string) {
log.Println(err.Error()) log.Println(err.Error())
return return
} }
writer.WriteHeader(204)
}) })
log.Fatal(http.ListenAndServe(endpoint, nil)) log.Fatal(http.ListenAndServe(endpoint, nil))
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment