Remove unneeded index handler
This commit is contained in:
parent
ef7e54055e
commit
0f521020c8
3 changed files with 1 additions and 47 deletions
|
@ -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)
|
||||
})
|
||||
}
|
|
@ -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)
|
||||
}
|
||||
}
|
2
main.go
2
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.
|
||||
|
|
Loading…
Reference in a new issue