2024-06-22 20:05:11 +00:00
|
|
|
package live
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
2024-06-23 12:12:06 +00:00
|
|
|
// New creates a new handler that returns "OK" for GET and HEAD requests.
|
2024-06-22 20:05:11 +00:00
|
|
|
func New() http.Handler {
|
2024-06-23 12:12:06 +00:00
|
|
|
var body = []byte("OK\n")
|
2024-06-22 20:05:11 +00:00
|
|
|
|
|
|
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
2024-06-23 12:12:06 +00:00
|
|
|
switch r.Method {
|
|
|
|
case http.MethodGet:
|
|
|
|
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
|
|
|
|
w.WriteHeader(http.StatusOK)
|
|
|
|
_, _ = w.Write(body)
|
|
|
|
|
|
|
|
case http.MethodHead:
|
|
|
|
w.WriteHeader(http.StatusOK)
|
|
|
|
|
|
|
|
default:
|
|
|
|
http.Error(w, http.StatusText(http.StatusMethodNotAllowed), http.StatusMethodNotAllowed)
|
|
|
|
}
|
2024-06-22 20:05:11 +00:00
|
|
|
})
|
|
|
|
}
|