diff --git a/index-view.go b/index-view.go deleted file mode 100644 index 45a60e7..0000000 --- a/index-view.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -import "net/http" - -// IndexViewHandler forwards to "/buckets" -func IndexViewHandler() http.Handler { - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - http.Redirect(w, r, "/buckets", http.StatusPermanentRedirect) - }) -} diff --git a/index-view_test.go b/index-view_test.go deleted file mode 100644 index f3f59a6..0000000 --- a/index-view_test.go +++ /dev/null @@ -1,36 +0,0 @@ -package main - -import ( - "net/http" - "net/http/httptest" - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestIndexViewHandler(t *testing.T) { - assert := assert.New(t) - - tests := map[string]struct { - expectedStatusCode int - expectedBodyContains string - }{ - "success": { - expectedStatusCode: http.StatusPermanentRedirect, - expectedBodyContains: "Redirect", - }, - } - - for tcID, tc := range tests { - req, err := http.NewRequest(http.MethodGet, "/", nil) - assert.NoError(err, tcID) - - rr := httptest.NewRecorder() - handler := IndexViewHandler() - - handler.ServeHTTP(rr, req) - - assert.Equal(tc.expectedStatusCode, rr.Code, tcID) - assert.Contains(rr.Body.String(), tc.expectedBodyContains, tcID) - } -} diff --git a/main.go b/main.go index de32c91..b252586 100644 --- a/main.go +++ b/main.go @@ -31,7 +31,7 @@ func main() { Methods(http.MethodGet). Path("/"). Handler(adapters.Adapt( - IndexViewHandler(), + http.RedirectHandler("/buckets", http.StatusPermanentRedirect), logging.Handler(logger), )) r.