diff options
-rw-r--r-- | http.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/http.go b/http.go index f46904f..ab6050f 100644 --- a/http.go +++ b/http.go @@ -21,6 +21,11 @@ func validateRequest(w http.ResponseWriter, r *http.Request) { return } + if r.URL.Path == "/" { + indexHandler(w, r) + return + } + format := formatHop(r) if format != "plain" && format != "json" { errHTTP(w, r, errors.New("400 Bad Request"), http.StatusBadRequest) @@ -69,3 +74,15 @@ func routingHop(r *http.Request) string { split := strings.Split(r.URL.Path[1:], "/") return split[1] } + +// Yeets the index/summary page to the user +func indexHandler(w http.ResponseWriter, r *http.Request) { + w.Header().Add("Content-Type", mimePlain) + out := []byte("This is the tilde.institute informational API") + _, err := w.Write(out) + if err != nil { + errHTTP(w, r, err, http.StatusInternalServerError) + return + } + log200(r) +} |