diff options
author | Ben Morrison <ben@gbmor.dev> | 2020-05-07 01:40:00 -0400 |
---|---|---|
committer | Ben Morrison <ben@gbmor.dev> | 2020-05-07 01:40:00 -0400 |
commit | 95266218c377f8bf4ae422208a5c872c9e3ac90f (patch) | |
tree | 102b796c67cde6c2b3fa60b2bc2e1839117961ba | |
parent | f9b16cd6aba68afc782ec7e5ac7075e134135512 (diff) | |
download | api-95266218c377f8bf4ae422208a5c872c9e3ac90f.tar.gz |
added handler for /
-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) +} |