From 24cf06d2885fcdd5c732694150d25c6021500072 Mon Sep 17 00:00:00 2001 From: fuxiaohei Date: Mon, 23 Feb 2015 11:15:55 +0800 Subject: [PATCH] code style simplify for context package --- context/context.go | 5 ++++- context/input.go | 8 ++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/context/context.go b/context/context.go index 89b5ffe4..b60650a8 100644 --- a/context/context.go +++ b/context/context.go @@ -155,8 +155,11 @@ func (ctx *Context) CheckXsrfCookie() bool { } if token == "" { ctx.Abort(403, "'_xsrf' argument missing from POST") - } else if ctx._xsrf_token != token { + return false + } + if ctx._xsrf_token != token { ctx.Abort(403, "XSRF cookie does not match POST argument") + return false } return true } diff --git a/context/input.go b/context/input.go index d9aa2634..f535e6a2 100644 --- a/context/input.go +++ b/context/input.go @@ -72,11 +72,11 @@ func (input *BeegoInput) Site() string { func (input *BeegoInput) Scheme() string { if input.Request.URL.Scheme != "" { return input.Request.URL.Scheme - } else if input.Request.TLS == nil { - return "http" - } else { - return "https" } + if input.Request.TLS == nil { + return "http" + } + return "https" } // Domain returns host name.