I testing a redirect about echo when I just use the method to redirect it can show the login.html page successfully, but if I use a middleware test, it always shows empty page of login.html
, what am I missing?
e.Group("*.html", func(next echo.HandlerFunc) echo.HandlerFunc { //1
return func(c echo.Context) error {
uri := c.Request().URL.String()
log.Println("uri:" + uri)
if uri != "/login.html" && uri != "/favicon.ico" {
c.Redirect(http.StatusSeeOther, "login.html")
return nil
}
return nil
}
})
e.Use(session.Middleware(sessions.NewCookieStore([]byte("secret"))))
e.GET("/aa", func(c echo.Context) error { //2
c.Redirect(http.StatusSeeOther, "login.html")
return nil
})