Context Accepted is an exported variable

This commit is contained in:
Manu Mtz-Almeida 2015-04-07 23:28:36 +02:00
parent 408108f4e7
commit 1532be7c10

View File

@ -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,14 +293,13 @@ 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 _, accepted := range c.Accepted {
for _, offert := range offered {
if accepted == offert {
return offert
@ -308,9 +307,8 @@ func (c *Context) NegotiateFormat(offered ...string) string {
}
}
return ""
}
}
func (c *Context) SetAccepted(formats ...string) {
c.accepted = formats
c.Accepted = formats
}