You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
497 B
Go

1 year ago
package main
import (
"encoding/json"
"log"
"mime"
"net/http"
)
func main() {
r := http.NewServeMux()
r.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodGet {
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
return
}
w.Header().Set("Content-Type", mime.TypeByExtension(".json"))
if err := json.NewEncoder(w).Encode("ok"); err != nil {
log.Fatal(err)
return
}
})
log.Fatal(http.ListenAndServe(":4000", r))
}