forked from datatogether/api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhandlers.go
29 lines (24 loc) · 838 Bytes
/
handlers.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package main
import (
"io"
"net/http"
)
// HealthCheckHandler is a basic "hey I'm fine" for load balancers & co
// TODO - add Database connection & proper configuration checks here for more accurate
// health reporting
func HealthCheckHandler(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
w.Write([]byte(`{ "status" : 200 }`))
}
func CertbotHandler(w http.ResponseWriter, r *http.Request) {
io.WriteString(w, cfg.CertbotResponse)
}
func NotFoundHandler(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusNotFound)
w.Write([]byte(`{ "status" : "not found" }`))
}
// EmptyOkHandler is an empty 200 response, often used
// for OPTIONS requests that responds with headers set in addCorsHeaders
func EmptyOkHandler(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
}