From 821b2f832ead32422b92a675d089f9710028be0d Mon Sep 17 00:00:00 2001 From: astaxie Date: Mon, 9 Nov 2015 11:03:57 +0800 Subject: [PATCH] fix the type assert --- context/output.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/context/output.go b/context/output.go index a4bb3d09..d132e392 100644 --- a/context/output.go +++ b/context/output.go @@ -103,7 +103,19 @@ func (output *BeegoOutput) Cookie(name string, value string, others ...interface //fix cookie not work in IE if len(others) > 0 { switch v := others[0].(type) { - case int, int32, int64: + case int: + if v > 0 { + fmt.Fprintf(&b, "; Expires=%s; Max-Age=%d", time.Now().Add(time.Duration(v)*time.Second).UTC().Format(time.RFC1123), v) + } else if v <= 0 { + fmt.Fprintf(&b, "; Max-Age=0") + } + case int64: + if v > 0 { + fmt.Fprintf(&b, "; Expires=%s; Max-Age=%d", time.Now().Add(time.Duration(v)*time.Second).UTC().Format(time.RFC1123), v) + } else if v <= 0 { + fmt.Fprintf(&b, "; Max-Age=0") + } + case int32: if v > 0 { fmt.Fprintf(&b, "; Expires=%s; Max-Age=%d", time.Now().Add(time.Duration(v)*time.Second).UTC().Format(time.RFC1123), v) } else if v <= 0 {