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