From 6ea52301f43138322f0a59cd4b7ca07c627db13d Mon Sep 17 00:00:00 2001 From: Denis Arh Date: Mon, 22 Oct 2018 13:24:04 +0200 Subject: [PATCH] Fix multipart codegen --- codegen/templates/http_request_inline.tpl | 13 +-- crm/rest/request/field.go | 18 ++-- crm/rest/request/module.go | 90 +++++++++-------- crm/rest/request/page.go | 45 +++++---- sam/rest/request/attachment.go | 18 ++-- sam/rest/request/channel.go | 100 +++++++++--------- sam/rest/request/message.go | 117 ++++++++++++---------- sam/rest/request/organisation.go | 54 +++++----- sam/rest/request/team.go | 72 +++++++------ sam/rest/request/user.go | 9 +- 10 files changed, 295 insertions(+), 241 deletions(-) diff --git a/codegen/templates/http_request_inline.tpl b/codegen/templates/http_request_inline.tpl index 29ac06051..964875076 100644 --- a/codegen/templates/http_request_inline.tpl +++ b/codegen/templates/http_request_inline.tpl @@ -31,9 +31,7 @@ func New{name|expose}{call.name|capitalize}() *{name|expose}{call.name|capitaliz return &{name|expose}{call.name|capitalize}{} } -func ({self} *{name|expose}{call.name|capitalize}) Fill(r *http.Request) error { - var err error - +func ({self} *{name|expose}{call.name|capitalize}) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode({self}) @@ -45,9 +43,12 @@ func ({self} *{name|expose}{call.name|capitalize}) Fill(r *http.Request) error { } } -{eval $parseForm = "ParseForm"} -{foreach $call.parameters as $method => $params}{foreach $params as $param}{if $param.type === "*multipart.FileHeader"}{eval $parseForm = "ParseMultipartForm"}{/if}{/foreach}{/foreach} - r.{$parseForm}() +{eval $parseForm = "ParseForm()"} +{foreach $call.parameters as $method => $params}{foreach $params as $param}{if $param.type === "*multipart.FileHeader"}{eval $parseForm = "ParseMultipartForm(32 << 20)"}{/if}{/foreach}{/foreach} + if err = r.{$parseForm}; err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() diff --git a/crm/rest/request/field.go b/crm/rest/request/field.go index c0637b57d..01c4eb3eb 100644 --- a/crm/rest/request/field.go +++ b/crm/rest/request/field.go @@ -38,9 +38,7 @@ func NewFieldList() *FieldList { return &FieldList{} } -func (f *FieldList) Fill(r *http.Request) error { - var err error - +func (f *FieldList) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(f) @@ -52,7 +50,10 @@ func (f *FieldList) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -78,9 +79,7 @@ func NewFieldType() *FieldType { return &FieldType{} } -func (f *FieldType) Fill(r *http.Request) error { - var err error - +func (f *FieldType) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(f) @@ -92,7 +91,10 @@ func (f *FieldType) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() diff --git a/crm/rest/request/module.go b/crm/rest/request/module.go index 938d16baf..c2773bc1a 100644 --- a/crm/rest/request/module.go +++ b/crm/rest/request/module.go @@ -39,9 +39,7 @@ func NewModuleList() *ModuleList { return &ModuleList{} } -func (m *ModuleList) Fill(r *http.Request) error { - var err error - +func (m *ModuleList) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(m) @@ -53,7 +51,10 @@ func (m *ModuleList) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -85,9 +86,7 @@ func NewModuleCreate() *ModuleCreate { return &ModuleCreate{} } -func (m *ModuleCreate) Fill(r *http.Request) error { - var err error - +func (m *ModuleCreate) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(m) @@ -99,7 +98,10 @@ func (m *ModuleCreate) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -136,9 +138,7 @@ func NewModuleRead() *ModuleRead { return &ModuleRead{} } -func (m *ModuleRead) Fill(r *http.Request) error { - var err error - +func (m *ModuleRead) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(m) @@ -150,7 +150,10 @@ func (m *ModuleRead) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -180,9 +183,7 @@ func NewModuleEdit() *ModuleEdit { return &ModuleEdit{} } -func (m *ModuleEdit) Fill(r *http.Request) error { - var err error - +func (m *ModuleEdit) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(m) @@ -194,7 +195,10 @@ func (m *ModuleEdit) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -232,9 +236,7 @@ func NewModuleDelete() *ModuleDelete { return &ModuleDelete{} } -func (m *ModuleDelete) Fill(r *http.Request) error { - var err error - +func (m *ModuleDelete) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(m) @@ -246,7 +248,10 @@ func (m *ModuleDelete) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -276,9 +281,7 @@ func NewModuleContentList() *ModuleContentList { return &ModuleContentList{} } -func (m *ModuleContentList) Fill(r *http.Request) error { - var err error - +func (m *ModuleContentList) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(m) @@ -290,7 +293,10 @@ func (m *ModuleContentList) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -327,9 +333,7 @@ func NewModuleContentCreate() *ModuleContentCreate { return &ModuleContentCreate{} } -func (m *ModuleContentCreate) Fill(r *http.Request) error { - var err error - +func (m *ModuleContentCreate) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(m) @@ -341,7 +345,10 @@ func (m *ModuleContentCreate) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -376,9 +383,7 @@ func NewModuleContentRead() *ModuleContentRead { return &ModuleContentRead{} } -func (m *ModuleContentRead) Fill(r *http.Request) error { - var err error - +func (m *ModuleContentRead) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(m) @@ -390,7 +395,10 @@ func (m *ModuleContentRead) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -421,9 +429,7 @@ func NewModuleContentEdit() *ModuleContentEdit { return &ModuleContentEdit{} } -func (m *ModuleContentEdit) Fill(r *http.Request) error { - var err error - +func (m *ModuleContentEdit) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(m) @@ -435,7 +441,10 @@ func (m *ModuleContentEdit) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -471,9 +480,7 @@ func NewModuleContentDelete() *ModuleContentDelete { return &ModuleContentDelete{} } -func (m *ModuleContentDelete) Fill(r *http.Request) error { - var err error - +func (m *ModuleContentDelete) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(m) @@ -485,7 +492,10 @@ func (m *ModuleContentDelete) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() diff --git a/crm/rest/request/page.go b/crm/rest/request/page.go index 2c76119a4..8794a3bd4 100644 --- a/crm/rest/request/page.go +++ b/crm/rest/request/page.go @@ -38,9 +38,7 @@ func NewPageList() *PageList { return &PageList{} } -func (p *PageList) Fill(r *http.Request) error { - var err error - +func (p *PageList) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(p) @@ -52,7 +50,10 @@ func (p *PageList) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -83,9 +84,7 @@ func NewPageCreate() *PageCreate { return &PageCreate{} } -func (p *PageCreate) Fill(r *http.Request) error { - var err error - +func (p *PageCreate) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(p) @@ -97,7 +96,10 @@ func (p *PageCreate) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -150,9 +152,7 @@ func NewPageRead() *PageRead { return &PageRead{} } -func (p *PageRead) Fill(r *http.Request) error { - var err error - +func (p *PageRead) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(p) @@ -164,7 +164,10 @@ func (p *PageRead) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -198,9 +201,7 @@ func NewPageEdit() *PageEdit { return &PageEdit{} } -func (p *PageEdit) Fill(r *http.Request) error { - var err error - +func (p *PageEdit) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(p) @@ -212,7 +213,10 @@ func (p *PageEdit) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -266,9 +270,7 @@ func NewPageDelete() *PageDelete { return &PageDelete{} } -func (p *PageDelete) Fill(r *http.Request) error { - var err error - +func (p *PageDelete) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(p) @@ -280,7 +282,10 @@ func (p *PageDelete) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() diff --git a/sam/rest/request/attachment.go b/sam/rest/request/attachment.go index 2912942d2..ee554a762 100644 --- a/sam/rest/request/attachment.go +++ b/sam/rest/request/attachment.go @@ -40,9 +40,7 @@ func NewAttachmentOriginal() *AttachmentOriginal { return &AttachmentOriginal{} } -func (a *AttachmentOriginal) Fill(r *http.Request) error { - var err error - +func (a *AttachmentOriginal) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(a) @@ -54,7 +52,10 @@ func (a *AttachmentOriginal) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -86,9 +87,7 @@ func NewAttachmentPreview() *AttachmentPreview { return &AttachmentPreview{} } -func (a *AttachmentPreview) Fill(r *http.Request) error { - var err error - +func (a *AttachmentPreview) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(a) @@ -100,7 +99,10 @@ func (a *AttachmentPreview) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() diff --git a/sam/rest/request/channel.go b/sam/rest/request/channel.go index 02f579c28..a56b89ed2 100644 --- a/sam/rest/request/channel.go +++ b/sam/rest/request/channel.go @@ -17,15 +17,13 @@ package request import ( "encoding/json" + "github.com/go-chi/chi" + "github.com/jmoiron/sqlx/types" + "github.com/pkg/errors" "io" "mime/multipart" "net/http" "strings" - - "github.com/davecgh/go-spew/spew" - "github.com/go-chi/chi" - "github.com/jmoiron/sqlx/types" - "github.com/pkg/errors" ) var _ = chi.URLParam @@ -41,9 +39,7 @@ func NewChannelList() *ChannelList { return &ChannelList{} } -func (c *ChannelList) Fill(r *http.Request) error { - var err error - +func (c *ChannelList) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(c) @@ -55,7 +51,10 @@ func (c *ChannelList) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -89,9 +88,7 @@ func NewChannelCreate() *ChannelCreate { return &ChannelCreate{} } -func (c *ChannelCreate) Fill(r *http.Request) error { - var err error - +func (c *ChannelCreate) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(c) @@ -103,7 +100,10 @@ func (c *ChannelCreate) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -147,9 +147,7 @@ func NewChannelEdit() *ChannelEdit { return &ChannelEdit{} } -func (c *ChannelEdit) Fill(r *http.Request) error { - var err error - +func (c *ChannelEdit) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(c) @@ -161,7 +159,10 @@ func (c *ChannelEdit) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -209,9 +210,7 @@ func NewChannelRead() *ChannelRead { return &ChannelRead{} } -func (c *ChannelRead) Fill(r *http.Request) error { - var err error - +func (c *ChannelRead) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(c) @@ -223,7 +222,10 @@ func (c *ChannelRead) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -251,9 +253,7 @@ func NewChannelDelete() *ChannelDelete { return &ChannelDelete{} } -func (c *ChannelDelete) Fill(r *http.Request) error { - var err error - +func (c *ChannelDelete) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(c) @@ -265,7 +265,10 @@ func (c *ChannelDelete) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -293,9 +296,7 @@ func NewChannelMembers() *ChannelMembers { return &ChannelMembers{} } -func (c *ChannelMembers) Fill(r *http.Request) error { - var err error - +func (c *ChannelMembers) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(c) @@ -307,7 +308,10 @@ func (c *ChannelMembers) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -336,9 +340,7 @@ func NewChannelJoin() *ChannelJoin { return &ChannelJoin{} } -func (c *ChannelJoin) Fill(r *http.Request) error { - var err error - +func (c *ChannelJoin) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(c) @@ -350,7 +352,10 @@ func (c *ChannelJoin) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -380,9 +385,7 @@ func NewChannelPart() *ChannelPart { return &ChannelPart{} } -func (c *ChannelPart) Fill(r *http.Request) error { - var err error - +func (c *ChannelPart) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(c) @@ -394,7 +397,10 @@ func (c *ChannelPart) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -424,9 +430,7 @@ func NewChannelInvite() *ChannelInvite { return &ChannelInvite{} } -func (c *ChannelInvite) Fill(r *http.Request) error { - var err error - +func (c *ChannelInvite) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(c) @@ -438,7 +442,10 @@ func (c *ChannelInvite) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -468,9 +475,7 @@ func NewChannelAttach() *ChannelAttach { return &ChannelAttach{} } -func (c *ChannelAttach) Fill(r *http.Request) error { - var err error - +func (c *ChannelAttach) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(c) @@ -482,7 +487,10 @@ func (c *ChannelAttach) Fill(r *http.Request) error { } } - r.ParseMultipartForm() + if err = r.ParseMultipartForm(32 << 20); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -494,8 +502,6 @@ func (c *ChannelAttach) Fill(r *http.Request) error { post[name] = string(param[0]) } - spew.Dump(post) - c.ChannelID = parseUInt64(chi.URLParam(r, "channelID")) if val, ok := post["replyTo"]; ok { diff --git a/sam/rest/request/message.go b/sam/rest/request/message.go index 3580d8cc1..a6898787a 100644 --- a/sam/rest/request/message.go +++ b/sam/rest/request/message.go @@ -40,9 +40,7 @@ func NewMessageCreate() *MessageCreate { return &MessageCreate{} } -func (m *MessageCreate) Fill(r *http.Request) error { - var err error - +func (m *MessageCreate) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(m) @@ -54,7 +52,10 @@ func (m *MessageCreate) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -87,9 +88,7 @@ func NewMessageHistory() *MessageHistory { return &MessageHistory{} } -func (m *MessageHistory) Fill(r *http.Request) error { - var err error - +func (m *MessageHistory) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(m) @@ -101,7 +100,10 @@ func (m *MessageHistory) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -135,9 +137,7 @@ func NewMessageEdit() *MessageEdit { return &MessageEdit{} } -func (m *MessageEdit) Fill(r *http.Request) error { - var err error - +func (m *MessageEdit) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(m) @@ -149,7 +149,10 @@ func (m *MessageEdit) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -183,9 +186,7 @@ func NewMessageDelete() *MessageDelete { return &MessageDelete{} } -func (m *MessageDelete) Fill(r *http.Request) error { - var err error - +func (m *MessageDelete) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(m) @@ -197,7 +198,10 @@ func (m *MessageDelete) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -228,9 +232,7 @@ func NewMessageSearch() *MessageSearch { return &MessageSearch{} } -func (m *MessageSearch) Fill(r *http.Request) error { - var err error - +func (m *MessageSearch) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(m) @@ -242,7 +244,10 @@ func (m *MessageSearch) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -279,9 +284,7 @@ func NewMessagePin() *MessagePin { return &MessagePin{} } -func (m *MessagePin) Fill(r *http.Request) error { - var err error - +func (m *MessagePin) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(m) @@ -293,7 +296,10 @@ func (m *MessagePin) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -323,9 +329,7 @@ func NewMessageGetReplies() *MessageGetReplies { return &MessageGetReplies{} } -func (m *MessageGetReplies) Fill(r *http.Request) error { - var err error - +func (m *MessageGetReplies) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(m) @@ -337,7 +341,10 @@ func (m *MessageGetReplies) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -368,9 +375,7 @@ func NewMessageCreateReply() *MessageCreateReply { return &MessageCreateReply{} } -func (m *MessageCreateReply) Fill(r *http.Request) error { - var err error - +func (m *MessageCreateReply) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(m) @@ -382,7 +387,10 @@ func (m *MessageCreateReply) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -416,9 +424,7 @@ func NewMessageUnpin() *MessageUnpin { return &MessageUnpin{} } -func (m *MessageUnpin) Fill(r *http.Request) error { - var err error - +func (m *MessageUnpin) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(m) @@ -430,7 +436,10 @@ func (m *MessageUnpin) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -460,9 +469,7 @@ func NewMessageFlag() *MessageFlag { return &MessageFlag{} } -func (m *MessageFlag) Fill(r *http.Request) error { - var err error - +func (m *MessageFlag) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(m) @@ -474,7 +481,10 @@ func (m *MessageFlag) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -504,9 +514,7 @@ func NewMessageUnflag() *MessageUnflag { return &MessageUnflag{} } -func (m *MessageUnflag) Fill(r *http.Request) error { - var err error - +func (m *MessageUnflag) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(m) @@ -518,7 +526,10 @@ func (m *MessageUnflag) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -549,9 +560,7 @@ func NewMessageReact() *MessageReact { return &MessageReact{} } -func (m *MessageReact) Fill(r *http.Request) error { - var err error - +func (m *MessageReact) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(m) @@ -563,7 +572,10 @@ func (m *MessageReact) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -595,9 +607,7 @@ func NewMessageUnreact() *MessageUnreact { return &MessageUnreact{} } -func (m *MessageUnreact) Fill(r *http.Request) error { - var err error - +func (m *MessageUnreact) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(m) @@ -609,7 +619,10 @@ func (m *MessageUnreact) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() diff --git a/sam/rest/request/organisation.go b/sam/rest/request/organisation.go index e4d815280..4328988a0 100644 --- a/sam/rest/request/organisation.go +++ b/sam/rest/request/organisation.go @@ -39,9 +39,7 @@ func NewOrganisationList() *OrganisationList { return &OrganisationList{} } -func (o *OrganisationList) Fill(r *http.Request) error { - var err error - +func (o *OrganisationList) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(o) @@ -53,7 +51,10 @@ func (o *OrganisationList) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -84,9 +85,7 @@ func NewOrganisationCreate() *OrganisationCreate { return &OrganisationCreate{} } -func (o *OrganisationCreate) Fill(r *http.Request) error { - var err error - +func (o *OrganisationCreate) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(o) @@ -98,7 +97,10 @@ func (o *OrganisationCreate) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -130,9 +132,7 @@ func NewOrganisationEdit() *OrganisationEdit { return &OrganisationEdit{} } -func (o *OrganisationEdit) Fill(r *http.Request) error { - var err error - +func (o *OrganisationEdit) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(o) @@ -144,7 +144,10 @@ func (o *OrganisationEdit) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -176,9 +179,7 @@ func NewOrganisationRemove() *OrganisationRemove { return &OrganisationRemove{} } -func (o *OrganisationRemove) Fill(r *http.Request) error { - var err error - +func (o *OrganisationRemove) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(o) @@ -190,7 +191,10 @@ func (o *OrganisationRemove) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -218,9 +222,7 @@ func NewOrganisationRead() *OrganisationRead { return &OrganisationRead{} } -func (o *OrganisationRead) Fill(r *http.Request) error { - var err error - +func (o *OrganisationRead) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(o) @@ -232,7 +234,10 @@ func (o *OrganisationRead) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -263,9 +268,7 @@ func NewOrganisationArchive() *OrganisationArchive { return &OrganisationArchive{} } -func (o *OrganisationArchive) Fill(r *http.Request) error { - var err error - +func (o *OrganisationArchive) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(o) @@ -277,7 +280,10 @@ func (o *OrganisationArchive) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() diff --git a/sam/rest/request/team.go b/sam/rest/request/team.go index d76d18acb..f2346d206 100644 --- a/sam/rest/request/team.go +++ b/sam/rest/request/team.go @@ -39,9 +39,7 @@ func NewTeamList() *TeamList { return &TeamList{} } -func (t *TeamList) Fill(r *http.Request) error { - var err error - +func (t *TeamList) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(t) @@ -53,7 +51,10 @@ func (t *TeamList) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -85,9 +86,7 @@ func NewTeamCreate() *TeamCreate { return &TeamCreate{} } -func (t *TeamCreate) Fill(r *http.Request) error { - var err error - +func (t *TeamCreate) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(t) @@ -99,7 +98,10 @@ func (t *TeamCreate) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -132,9 +134,7 @@ func NewTeamEdit() *TeamEdit { return &TeamEdit{} } -func (t *TeamEdit) Fill(r *http.Request) error { - var err error - +func (t *TeamEdit) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(t) @@ -146,7 +146,10 @@ func (t *TeamEdit) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -178,9 +181,7 @@ func NewTeamRead() *TeamRead { return &TeamRead{} } -func (t *TeamRead) Fill(r *http.Request) error { - var err error - +func (t *TeamRead) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(t) @@ -192,7 +193,10 @@ func (t *TeamRead) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -220,9 +224,7 @@ func NewTeamRemove() *TeamRemove { return &TeamRemove{} } -func (t *TeamRemove) Fill(r *http.Request) error { - var err error - +func (t *TeamRemove) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(t) @@ -234,7 +236,10 @@ func (t *TeamRemove) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -262,9 +267,7 @@ func NewTeamArchive() *TeamArchive { return &TeamArchive{} } -func (t *TeamArchive) Fill(r *http.Request) error { - var err error - +func (t *TeamArchive) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(t) @@ -276,7 +279,10 @@ func (t *TeamArchive) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -305,9 +311,7 @@ func NewTeamMove() *TeamMove { return &TeamMove{} } -func (t *TeamMove) Fill(r *http.Request) error { - var err error - +func (t *TeamMove) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(t) @@ -319,7 +323,10 @@ func (t *TeamMove) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() @@ -352,9 +359,7 @@ func NewTeamMerge() *TeamMerge { return &TeamMerge{} } -func (t *TeamMerge) Fill(r *http.Request) error { - var err error - +func (t *TeamMerge) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(t) @@ -366,7 +371,10 @@ func (t *TeamMerge) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query() diff --git a/sam/rest/request/user.go b/sam/rest/request/user.go index e4f5b2503..3360e0607 100644 --- a/sam/rest/request/user.go +++ b/sam/rest/request/user.go @@ -39,9 +39,7 @@ func NewUserSearch() *UserSearch { return &UserSearch{} } -func (u *UserSearch) Fill(r *http.Request) error { - var err error - +func (u *UserSearch) Fill(r *http.Request) (err error) { if strings.ToLower(r.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(r.Body).Decode(u) @@ -53,7 +51,10 @@ func (u *UserSearch) Fill(r *http.Request) error { } } - r.ParseForm() + if err = r.ParseForm(); err != nil { + return err + } + get := map[string]string{} post := map[string]string{} urlQuery := r.URL.Query()