Explorar o código

Tail call optimization

Manu Mtz-Almeida %!s(int64=11) %!d(string=hai) anos
pai
achega
79131ac84d
Modificáronse 1 ficheiros con 2 adicións e 3 borrados
  1. 2 3
      context.go

+ 2 - 3
context.go

@@ -356,11 +356,10 @@ func (c *Context) HTMLString(code int, format string, values ...interface{}) {
 
 
 // Returns a HTTP redirect to the specific location.
 // Returns a HTTP redirect to the specific location.
 func (c *Context) Redirect(code int, location string) {
 func (c *Context) Redirect(code int, location string) {
-	if code >= 300 && code <= 308 {
-		c.Render(code, render.Redirect, c.Request, location)
-	} else {
+	if code < 300 || code > 308 {
 		panic(fmt.Sprintf("Cannot redirect with status code %d", code))
 		panic(fmt.Sprintf("Cannot redirect with status code %d", code))
 	}
 	}
+	c.Render(code, render.Redirect, c.Request, location)
 }
 }
 
 
 // Writes some data into the body stream and updates the HTTP code.
 // Writes some data into the body stream and updates the HTTP code.