Fix Vars fetching

This commit is contained in:
spsobole 2023-05-29 14:38:37 -06:00
parent 15a8fed766
commit 2b4999c73d
2 changed files with 6 additions and 12 deletions

View File

@ -8,6 +8,7 @@ import (
"net/http" "net/http"
"git.twelvetwelve.org/library/snap/auth" "git.twelvetwelve.org/library/snap/auth"
"github.com/gorilla/mux"
) )
type Context struct { type Context struct {
@ -191,21 +192,13 @@ func (c *Context) ReadObject(object interface{}) error {
} }
func (c *Context) ParseVars() *Options { func (c *Context) ParseVars() *Options {
if c.form != nil { if c.vars == nil {
return &Options{ c.vars = &Vars{
kv: c.form, vars: mux.Vars(c.r),
} }
} }
err := c.r.ParseForm()
if err != nil {
return nil
}
c.form = &Form{
r: c.r,
}
return &Options{ return &Options{
kv: c.form, kv: c.vars,
} }
} }

View File

@ -57,6 +57,7 @@ func (s *Server) makeContext(auth *auth.AuthData, w http.ResponseWriter, r *http
w: w, w: w,
srv: s, srv: s,
auth: auth, auth: auth,
vars: mux.Vars(r),
} }
return c return c
} }