Fix multival (string) requst param parsing (for POST)

This commit is contained in:
Denis Arh
2019-06-21 14:23:12 +02:00
parent b7f78cdf91
commit 8309e6e710
7 changed files with 33 additions and 11 deletions
+3 -1
View File
@@ -81,7 +81,9 @@ func (r *{name|expose}{call.name|capitalize}) Fill(req *http.Request) (err error
r.{param.name|expose} = {if ($param.type !== "string")}{$parsers[$param.type]}({/if}chi.URLParam(req, "{param.name}"){if ($param.type !== "string")}){/if}
{elseif (substr($param.type, 0, 2) === '[]' || substr($param.type, -3) === "Set") && isset($parsers[$param.type])}
{if strtolower($method) === "post"}
r.{param.name|expose} = {$parsers[$param.type]}(req.Form["{param.name}"])
if val, ok := req.Form["{param.name}"]; ok {
r.{param.name|expose} = {$parsers[$param.type]}(val)
}
{elseif strtolower($method) === "get"}
if val, ok := urlQuery["{param.name}[]"]; ok {
r.{param.name|expose} = {$parsers[$param.type]}(val)
+6 -2
View File
@@ -84,9 +84,13 @@ func (r *NotificationEmailSend) Fill(req *http.Request) (err error) {
post[name] = string(param[0])
}
r.To = parseStrings(req.Form["to"])
if val, ok := req.Form["to"]; ok {
r.To = parseStrings(val)
}
r.Cc = parseStrings(req.Form["cc"])
if val, ok := req.Form["cc"]; ok {
r.Cc = parseStrings(val)
}
if val, ok := post["replyTo"]; ok {
r.ReplyTo = val
+3 -1
View File
@@ -430,7 +430,9 @@ func (r *PageReorder) Fill(req *http.Request) (err error) {
r.SelfID = parseUInt64(chi.URLParam(req, "selfID"))
r.NamespaceID = parseUInt64(chi.URLParam(req, "namespaceID"))
r.PageIDs = parseStrings(req.Form["pageIDs"])
if val, ok := req.Form["pageIDs"]; ok {
r.PageIDs = parseStrings(val)
}
return err
}
+6 -2
View File
@@ -166,7 +166,9 @@ func (r *TriggerCreate) Fill(req *http.Request) (err error) {
r.Name = val
}
r.Actions = parseStrings(req.Form["actions"])
if val, ok := req.Form["actions"]; ok {
r.Actions = parseStrings(val)
}
if val, ok := post["enabled"]; ok {
r.Enabled = parseBool(val)
@@ -306,7 +308,9 @@ func (r *TriggerUpdate) Fill(req *http.Request) (err error) {
r.Name = val
}
r.Actions = parseStrings(req.Form["actions"])
if val, ok := req.Form["actions"]; ok {
r.Actions = parseStrings(val)
}
if val, ok := post["enabled"]; ok {
r.Enabled = parseBool(val)
+6 -2
View File
@@ -143,7 +143,9 @@ func (r *ChannelCreate) Fill(req *http.Request) (err error) {
r.Type = val
}
r.Members = parseStrings(req.Form["members"])
if val, ok := req.Form["members"]; ok {
r.Members = parseStrings(val)
}
return err
}
@@ -642,7 +644,9 @@ func (r *ChannelInvite) Fill(req *http.Request) (err error) {
r.ChannelID = parseUInt64(chi.URLParam(req, "channelID"))
r.UserID = parseStrings(req.Form["userID"])
if val, ok := req.Form["userID"]; ok {
r.UserID = parseStrings(val)
}
return err
}
+3 -1
View File
@@ -143,7 +143,9 @@ func (r *MessageExecuteCommand) Fill(req *http.Request) (err error) {
r.Input = val
}
r.Params = parseStrings(req.Form["params"])
if val, ok := req.Form["params"]; ok {
r.Params = parseStrings(val)
}
return err
}
+6 -2
View File
@@ -133,7 +133,9 @@ func (r *RoleCreate) Fill(req *http.Request) (err error) {
r.Name = val
}
r.Members = parseStrings(req.Form["members"])
if val, ok := req.Form["members"]; ok {
r.Members = parseStrings(val)
}
return err
}
@@ -193,7 +195,9 @@ func (r *RoleUpdate) Fill(req *http.Request) (err error) {
r.Name = val
}
r.Members = parseStrings(req.Form["members"])
if val, ok := req.Form["members"]; ok {
r.Members = parseStrings(val)
}
return err
}