From 1532be7c10088903707ecd0805951027ebb041e5 Mon Sep 17 00:00:00 2001 From: Manu Mtz-Almeida Date: Tue, 7 Apr 2015 23:28:36 +0200 Subject: [PATCH] Context Accepted is an exported variable --- context.go | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/context.go b/context.go index e876842..20be5fe 100644 --- a/context.go +++ b/context.go @@ -33,7 +33,7 @@ type Context struct { Keys map[string]interface{} Errors errorMsgs - accepted []string + Accepted []string } /************************************/ @@ -43,7 +43,7 @@ type Context struct { func (c *Context) reset() { c.Keys = nil c.index = -1 - c.accepted = nil + c.Accepted = nil c.Errors = c.Errors[0:0] } @@ -293,24 +293,22 @@ func (c *Context) NegotiateFormat(offered ...string) string { if len(offered) == 0 { log.Panic("you must provide at least one offer") } - if c.accepted == nil { - c.accepted = parseAccept(c.Request.Header.Get("Accept")) + if c.Accepted == nil { + c.Accepted = parseAccept(c.Request.Header.Get("Accept")) } - if len(c.accepted) == 0 { + if len(c.Accepted) == 0 { return offered[0] - - } else { - for _, accepted := range c.accepted { - for _, offert := range offered { - if accepted == offert { - return offert - } + } + for _, accepted := range c.Accepted { + for _, offert := range offered { + if accepted == offert { + return offert } } - return "" } + return "" } func (c *Context) SetAccepted(formats ...string) { - c.accepted = formats + c.Accepted = formats }