Skip to content
Snippets Groups Projects
Commit f250bba4 authored by Will McCutchen's avatar Will McCutchen
Browse files

Stricter index handler

parent 0b5fd397
No related branches found
No related tags found
No related merge requests found
......@@ -18,6 +18,10 @@ var acceptedMediaTypes = []string{
// Index renders an HTML index page
func (h *HTTPBin) Index(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != "/" {
http.Error(w, "Not Found", http.StatusNotFound)
return
}
w.Write(MustAsset("index.html"))
}
......
......@@ -59,6 +59,13 @@ func TestIndex(t *testing.T) {
assertBodyContains(t, w, "go-httpbin")
}
func TestIndex__NotFound(t *testing.T) {
r, _ := http.NewRequest("GET", "/foo", nil)
w := httptest.NewRecorder()
handler.ServeHTTP(w, r)
assertStatusCode(t, w, http.StatusNotFound)
}
func TestFormsPost(t *testing.T) {
r, _ := http.NewRequest("GET", "/forms/post", nil)
w := httptest.NewRecorder()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment