1
0
mirror of https://github.com/astaxie/beego.git synced 2024-12-22 17:00:50 +00:00

Log redirects and abort after redirect

This commit is contained in:
Waleed Gadelkareem 2018-04-30 17:48:01 +02:00
parent 33bf80b052
commit 896c258e44
2 changed files with 2 additions and 2 deletions

View File

@ -272,7 +272,9 @@ func (c *Controller) viewPath() string {
// Redirect sends the redirection response to url with status code.
func (c *Controller) Redirect(url string, code int) {
logAccess(c.Ctx, nil, code)
c.Ctx.Redirect(code, url)
panic(ErrAbort)
}
// Abort stops controller handler and show the error data if code is defined in ErrorMap or code string.

View File

@ -64,9 +64,7 @@ func disableEscapeHTML(i interface{}) {
// AccessLog - Format and print access log.
func AccessLog(r *AccessLogRecord, format string) {
var msg string
switch format {
case apacheFormat:
timeFormatted := r.RequestTime.Format("02/Jan/2006 03:04:05")
msg = fmt.Sprintf(apacheFormatPattern, r.RemoteAddr, timeFormatted, r.Request, r.Status, r.BodyBytesSent,