Redirect
重定向当前请求。
Example
package main
import (
"github.com/vicanso/elton"
"github.com/vicanso/elton/middleware"
)
func main() {
e := elton.New()
e.Use(middleware.NewDefaultResponder())
e.GET("/", func(c *elton.Context) (err error) {
c.Body = "Hello, World!"
return
})
e.GET("/redirect", func(c *elton.Context) (err error) {
err = c.Redirect(301, "/")
return
})
err := e.ListenAndServe(":3000")
if err != nil {
panic(err)
}
}