mirror of
https://github.com/astaxie/beego.git
synced 2024-11-25 04:20:55 +00:00
remove Redirect to avoid confusion
This commit is contained in:
parent
3e51823c0f
commit
2513bcf584
@ -16,13 +16,6 @@ const (
|
|||||||
NotFound StatusCode = http.StatusNotFound
|
NotFound StatusCode = http.StatusNotFound
|
||||||
)
|
)
|
||||||
|
|
||||||
// Redirect renders http 302 with a URL
|
|
||||||
func Redirect(localurl string) error {
|
|
||||||
return statusCodeWithRender{302, func(ctx *beecontext.Context) {
|
|
||||||
ctx.Redirect(302, localurl)
|
|
||||||
}}
|
|
||||||
}
|
|
||||||
|
|
||||||
// StatusCode sets the http response status code
|
// StatusCode sets the http response status code
|
||||||
type StatusCode int
|
type StatusCode int
|
||||||
|
|
||||||
@ -34,19 +27,3 @@ func (s StatusCode) Error() string {
|
|||||||
func (s StatusCode) Render(ctx *beecontext.Context) {
|
func (s StatusCode) Render(ctx *beecontext.Context) {
|
||||||
ctx.Output.SetStatus(int(s))
|
ctx.Output.SetStatus(int(s))
|
||||||
}
|
}
|
||||||
|
|
||||||
type statusCodeWithRender struct {
|
|
||||||
statusCode int
|
|
||||||
f func(ctx *beecontext.Context)
|
|
||||||
}
|
|
||||||
|
|
||||||
//assert that statusCodeWithRender implements Renderer interface
|
|
||||||
var _r beecontext.Renderer = (*statusCodeWithRender)(nil)
|
|
||||||
|
|
||||||
func (s statusCodeWithRender) Error() string {
|
|
||||||
return strconv.Itoa(s.statusCode)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s statusCodeWithRender) Render(ctx *beecontext.Context) {
|
|
||||||
s.f(ctx)
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user