diff --git a/automation/rest/request/eventTypes.go b/automation/rest/request/eventTypes.go index 4a36d3082..25359f1e6 100644 --- a/automation/rest/request/eventTypes.go +++ b/automation/rest/request/eventTypes.go @@ -25,6 +25,10 @@ var ( _ = chi.URLParam _ = multipart.ErrMessageTooLarge _ = payload.ParseUint64s + _ = strings.ToLower + _ = io.EOF + _ = fmt.Errorf + _ = json.NewEncoder ) type ( @@ -45,16 +49,6 @@ func (r EventTypesList) Auditable() map[string]interface{} { // Fill processes request and fills internal variables func (r *EventTypesList) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } return err } diff --git a/automation/rest/request/function.go b/automation/rest/request/function.go index b7b462c90..93ec8372c 100644 --- a/automation/rest/request/function.go +++ b/automation/rest/request/function.go @@ -25,6 +25,10 @@ var ( _ = chi.URLParam _ = multipart.ErrMessageTooLarge _ = payload.ParseUint64s + _ = strings.ToLower + _ = io.EOF + _ = fmt.Errorf + _ = json.NewEncoder ) type ( @@ -45,16 +49,6 @@ func (r FunctionList) Auditable() map[string]interface{} { // Fill processes request and fills internal variables func (r *FunctionList) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } return err } diff --git a/automation/rest/request/permissions.go b/automation/rest/request/permissions.go index bbee21dd7..3241cae68 100644 --- a/automation/rest/request/permissions.go +++ b/automation/rest/request/permissions.go @@ -26,6 +26,10 @@ var ( _ = chi.URLParam _ = multipart.ErrMessageTooLarge _ = payload.ParseUint64s + _ = strings.ToLower + _ = io.EOF + _ = fmt.Errorf + _ = json.NewEncoder ) type ( @@ -79,16 +83,6 @@ func (r PermissionsList) Auditable() map[string]interface{} { // Fill processes request and fills internal variables func (r *PermissionsList) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } return err } @@ -112,16 +106,6 @@ func (r PermissionsEffective) GetResource() string { // Fill processes request and fills internal variables func (r *PermissionsEffective) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { // GET params @@ -157,16 +141,6 @@ func (r PermissionsRead) GetRoleID() uint64 { // Fill processes request and fills internal variables func (r *PermissionsRead) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -202,16 +176,6 @@ func (r PermissionsDelete) GetRoleID() uint64 { // Fill processes request and fills internal variables func (r *PermissionsDelete) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -253,6 +217,7 @@ func (r PermissionsUpdate) GetRules() rbac.RuleSet { // Fill processes request and fills internal variables func (r *PermissionsUpdate) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) diff --git a/automation/rest/request/session.go b/automation/rest/request/session.go index 1954af174..60059d82c 100644 --- a/automation/rest/request/session.go +++ b/automation/rest/request/session.go @@ -27,6 +27,10 @@ var ( _ = chi.URLParam _ = multipart.ErrMessageTooLarge _ = payload.ParseUint64s + _ = strings.ToLower + _ = io.EOF + _ = fmt.Errorf + _ = json.NewEncoder ) type ( @@ -199,16 +203,6 @@ func (r SessionList) GetSort() string { // Fill processes request and fills internal variables func (r *SessionList) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { // GET params @@ -307,16 +301,6 @@ func (r SessionRead) GetSessionID() uint64 { // Fill processes request and fills internal variables func (r *SessionRead) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -352,16 +336,6 @@ func (r SessionTrace) GetSessionID() uint64 { // Fill processes request and fills internal variables func (r *SessionTrace) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -397,16 +371,6 @@ func (r SessionDelete) GetSessionID() uint64 { // Fill processes request and fills internal variables func (r *SessionDelete) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -435,16 +399,6 @@ func (r SessionListPrompts) Auditable() map[string]interface{} { // Fill processes request and fills internal variables func (r *SessionListPrompts) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } return err } @@ -480,6 +434,7 @@ func (r SessionResumeState) GetInput() *expr.Vars { // Fill processes request and fills internal variables func (r *SessionResumeState) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -557,16 +512,6 @@ func (r SessionDeleteState) GetStateID() uint64 { // Fill processes request and fills internal variables func (r *SessionDeleteState) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string diff --git a/automation/rest/request/trigger.go b/automation/rest/request/trigger.go index 113a2de01..610a08662 100644 --- a/automation/rest/request/trigger.go +++ b/automation/rest/request/trigger.go @@ -28,6 +28,10 @@ var ( _ = chi.URLParam _ = multipart.ErrMessageTooLarge _ = payload.ParseUint64s + _ = strings.ToLower + _ = io.EOF + _ = fmt.Errorf + _ = json.NewEncoder ) type ( @@ -299,16 +303,6 @@ func (r TriggerList) GetSort() string { // Fill processes request and fills internal variables func (r *TriggerList) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { // GET params @@ -473,6 +467,7 @@ func (r TriggerCreate) GetOwnedBy() uint64 { // Fill processes request and fills internal variables func (r *TriggerCreate) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -664,6 +659,7 @@ func (r TriggerUpdate) GetOwnedBy() uint64 { // Fill processes request and fills internal variables func (r *TriggerUpdate) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -807,16 +803,6 @@ func (r TriggerRead) GetTriggerID() uint64 { // Fill processes request and fills internal variables func (r *TriggerRead) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -852,16 +838,6 @@ func (r TriggerDelete) GetTriggerID() uint64 { // Fill processes request and fills internal variables func (r *TriggerDelete) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -897,16 +873,6 @@ func (r TriggerUndelete) GetTriggerID() uint64 { // Fill processes request and fills internal variables func (r *TriggerUndelete) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string diff --git a/automation/rest/request/type.go b/automation/rest/request/type.go index 528db3d47..3116aee1b 100644 --- a/automation/rest/request/type.go +++ b/automation/rest/request/type.go @@ -25,6 +25,10 @@ var ( _ = chi.URLParam _ = multipart.ErrMessageTooLarge _ = payload.ParseUint64s + _ = strings.ToLower + _ = io.EOF + _ = fmt.Errorf + _ = json.NewEncoder ) type ( @@ -45,16 +49,6 @@ func (r TypeList) Auditable() map[string]interface{} { // Fill processes request and fills internal variables func (r *TypeList) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } return err } diff --git a/automation/rest/request/workflow.go b/automation/rest/request/workflow.go index 1de80b991..8d580e3a2 100644 --- a/automation/rest/request/workflow.go +++ b/automation/rest/request/workflow.go @@ -28,6 +28,10 @@ var ( _ = chi.URLParam _ = multipart.ErrMessageTooLarge _ = payload.ParseUint64s + _ = strings.ToLower + _ = io.EOF + _ = fmt.Errorf + _ = json.NewEncoder ) type ( @@ -293,16 +297,6 @@ func (r WorkflowList) GetSort() string { // Fill processes request and fills internal variables func (r *WorkflowList) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { // GET params @@ -450,6 +444,7 @@ func (r WorkflowCreate) GetOwnedBy() uint64 { // Fill processes request and fills internal variables func (r *WorkflowCreate) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -659,6 +654,7 @@ func (r WorkflowUpdate) GetOwnedBy() uint64 { // Fill processes request and fills internal variables func (r *WorkflowUpdate) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -814,16 +810,6 @@ func (r WorkflowRead) GetWorkflowID() uint64 { // Fill processes request and fills internal variables func (r *WorkflowRead) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -859,16 +845,6 @@ func (r WorkflowDelete) GetWorkflowID() uint64 { // Fill processes request and fills internal variables func (r *WorkflowDelete) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -904,16 +880,6 @@ func (r WorkflowUndelete) GetWorkflowID() uint64 { // Fill processes request and fills internal variables func (r *WorkflowUndelete) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -961,6 +927,7 @@ func (r WorkflowTest) GetRunAs() bool { // Fill processes request and fills internal variables func (r *WorkflowTest) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) diff --git a/compose/rest/request/attachment.go b/compose/rest/request/attachment.go index 51dd4d9a6..e905ca350 100644 --- a/compose/rest/request/attachment.go +++ b/compose/rest/request/attachment.go @@ -25,6 +25,10 @@ var ( _ = chi.URLParam _ = multipart.ErrMessageTooLarge _ = payload.ParseUint64s + _ = strings.ToLower + _ = io.EOF + _ = fmt.Errorf + _ = json.NewEncoder ) type ( @@ -278,16 +282,6 @@ func (r AttachmentList) GetPageCursor() string { // Fill processes request and fills internal variables func (r *AttachmentList) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { // GET params @@ -407,16 +401,6 @@ func (r AttachmentRead) GetUserID() uint64 { // Fill processes request and fills internal variables func (r *AttachmentRead) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { // GET params @@ -506,16 +490,6 @@ func (r AttachmentDelete) GetUserID() uint64 { // Fill processes request and fills internal variables func (r *AttachmentDelete) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { // GET params @@ -617,16 +591,6 @@ func (r AttachmentOriginal) GetDownload() bool { // Fill processes request and fills internal variables func (r *AttachmentOriginal) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { // GET params @@ -734,16 +698,6 @@ func (r AttachmentPreview) GetUserID() uint64 { // Fill processes request and fills internal variables func (r *AttachmentPreview) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { // GET params diff --git a/compose/rest/request/automation.go b/compose/rest/request/automation.go index eca3335ce..c7a1c1961 100644 --- a/compose/rest/request/automation.go +++ b/compose/rest/request/automation.go @@ -25,6 +25,10 @@ var ( _ = chi.URLParam _ = multipart.ErrMessageTooLarge _ = payload.ParseUint64s + _ = strings.ToLower + _ = io.EOF + _ = fmt.Errorf + _ = json.NewEncoder ) type ( @@ -135,16 +139,6 @@ func (r AutomationList) GetExcludeServerScripts() bool { // Fill processes request and fills internal variables func (r *AutomationList) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { // GET params @@ -237,16 +231,6 @@ func (r AutomationBundle) GetExt() string { // Fill processes request and fills internal variables func (r *AutomationBundle) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -294,6 +278,7 @@ func (r AutomationTriggerScript) GetScript() string { // Fill processes request and fills internal variables func (r *AutomationTriggerScript) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) diff --git a/compose/rest/request/chart.go b/compose/rest/request/chart.go index 2f2183fc4..d03addd58 100644 --- a/compose/rest/request/chart.go +++ b/compose/rest/request/chart.go @@ -28,6 +28,10 @@ var ( _ = chi.URLParam _ = multipart.ErrMessageTooLarge _ = payload.ParseUint64s + _ = strings.ToLower + _ = io.EOF + _ = fmt.Errorf + _ = json.NewEncoder ) type ( @@ -213,16 +217,6 @@ func (r ChartList) GetSort() string { // Fill processes request and fills internal variables func (r *ChartList) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { // GET params @@ -329,6 +323,7 @@ func (r ChartCreate) GetLabels() map[string]string { // Fill processes request and fills internal variables func (r *ChartCreate) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -421,16 +416,6 @@ func (r ChartRead) GetChartID() uint64 { // Fill processes request and fills internal variables func (r *ChartRead) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -508,6 +493,7 @@ func (r ChartUpdate) GetUpdatedAt() *time.Time { // Fill processes request and fills internal variables func (r *ChartUpdate) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -613,16 +599,6 @@ func (r ChartDelete) GetChartID() uint64 { // Fill processes request and fills internal variables func (r *ChartDelete) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string diff --git a/compose/rest/request/module.go b/compose/rest/request/module.go index 45c74bbdf..ad2a60c43 100644 --- a/compose/rest/request/module.go +++ b/compose/rest/request/module.go @@ -29,6 +29,10 @@ var ( _ = chi.URLParam _ = multipart.ErrMessageTooLarge _ = payload.ParseUint64s + _ = strings.ToLower + _ = io.EOF + _ = fmt.Errorf + _ = json.NewEncoder ) type ( @@ -252,16 +256,6 @@ func (r ModuleList) GetSort() string { // Fill processes request and fills internal variables func (r *ModuleList) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { // GET params @@ -380,6 +374,7 @@ func (r ModuleCreate) GetLabels() map[string]string { // Fill processes request and fills internal variables func (r *ModuleCreate) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -479,16 +474,6 @@ func (r ModuleRead) GetModuleID() uint64 { // Fill processes request and fills internal variables func (r *ModuleRead) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -572,6 +557,7 @@ func (r ModuleUpdate) GetLabels() map[string]string { // Fill processes request and fills internal variables func (r *ModuleUpdate) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -684,16 +670,6 @@ func (r ModuleDelete) GetModuleID() uint64 { // Fill processes request and fills internal variables func (r *ModuleDelete) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -747,6 +723,7 @@ func (r ModuleTriggerScript) GetScript() string { // Fill processes request and fills internal variables func (r *ModuleTriggerScript) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) diff --git a/compose/rest/request/namespace.go b/compose/rest/request/namespace.go index 285227f19..21123b6dc 100644 --- a/compose/rest/request/namespace.go +++ b/compose/rest/request/namespace.go @@ -28,6 +28,10 @@ var ( _ = chi.URLParam _ = multipart.ErrMessageTooLarge _ = payload.ParseUint64s + _ = strings.ToLower + _ = io.EOF + _ = fmt.Errorf + _ = json.NewEncoder ) type ( @@ -211,16 +215,6 @@ func (r NamespaceList) GetSort() string { // Fill processes request and fills internal variables func (r *NamespaceList) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { // GET params @@ -315,6 +309,7 @@ func (r NamespaceCreate) GetMeta() sqlxTypes.JSONText { // Fill processes request and fills internal variables func (r *NamespaceCreate) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -396,16 +391,6 @@ func (r NamespaceRead) GetNamespaceID() uint64 { // Fill processes request and fills internal variables func (r *NamespaceRead) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -477,6 +462,7 @@ func (r NamespaceUpdate) GetUpdatedAt() *time.Time { // Fill processes request and fills internal variables func (r *NamespaceUpdate) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -577,16 +563,6 @@ func (r NamespaceDelete) GetNamespaceID() uint64 { // Fill processes request and fills internal variables func (r *NamespaceDelete) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -622,6 +598,7 @@ func (r NamespaceUpload) GetUpload() *multipart.FileHeader { // Fill processes request and fills internal variables func (r *NamespaceUpload) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -674,6 +651,7 @@ func (r NamespaceTriggerScript) GetScript() string { // Fill processes request and fills internal variables func (r *NamespaceTriggerScript) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) diff --git a/compose/rest/request/notification.go b/compose/rest/request/notification.go index d04f80d2d..a6dd41463 100644 --- a/compose/rest/request/notification.go +++ b/compose/rest/request/notification.go @@ -26,6 +26,10 @@ var ( _ = chi.URLParam _ = multipart.ErrMessageTooLarge _ = payload.ParseUint64s + _ = strings.ToLower + _ = io.EOF + _ = fmt.Errorf + _ = json.NewEncoder ) type ( @@ -112,6 +116,7 @@ func (r NotificationEmailSend) GetRemoteAttachments() []string { // Fill processes request and fills internal variables func (r *NotificationEmailSend) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) diff --git a/compose/rest/request/page.go b/compose/rest/request/page.go index 715a7fa6e..4e7887a93 100644 --- a/compose/rest/request/page.go +++ b/compose/rest/request/page.go @@ -27,6 +27,10 @@ var ( _ = chi.URLParam _ = multipart.ErrMessageTooLarge _ = payload.ParseUint64s + _ = strings.ToLower + _ = io.EOF + _ = fmt.Errorf + _ = json.NewEncoder ) type ( @@ -326,16 +330,6 @@ func (r PageList) GetSort() string { // Fill processes request and fills internal variables func (r *PageList) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { // GET params @@ -478,6 +472,7 @@ func (r PageCreate) GetBlocks() sqlxTypes.JSONText { // Fill processes request and fills internal variables func (r *PageCreate) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -605,16 +600,6 @@ func (r PageRead) GetPageID() uint64 { // Fill processes request and fills internal variables func (r *PageRead) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -656,16 +641,6 @@ func (r PageTree) GetNamespaceID() uint64 { // Fill processes request and fills internal variables func (r *PageTree) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -761,6 +736,7 @@ func (r PageUpdate) GetBlocks() sqlxTypes.JSONText { // Fill processes request and fills internal variables func (r *PageUpdate) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -900,6 +876,7 @@ func (r PageReorder) GetPageIDs() []string { // Fill processes request and fills internal variables func (r *PageReorder) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -972,16 +949,6 @@ func (r PageDelete) GetPageID() uint64 { // Fill processes request and fills internal variables func (r *PageDelete) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -1035,6 +1002,7 @@ func (r PageUpload) GetUpload() *multipart.FileHeader { // Fill processes request and fills internal variables func (r *PageUpload) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -1111,6 +1079,7 @@ func (r PageTriggerScript) GetScript() string { // Fill processes request and fills internal variables func (r *PageTriggerScript) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) diff --git a/compose/rest/request/permissions.go b/compose/rest/request/permissions.go index bbee21dd7..3241cae68 100644 --- a/compose/rest/request/permissions.go +++ b/compose/rest/request/permissions.go @@ -26,6 +26,10 @@ var ( _ = chi.URLParam _ = multipart.ErrMessageTooLarge _ = payload.ParseUint64s + _ = strings.ToLower + _ = io.EOF + _ = fmt.Errorf + _ = json.NewEncoder ) type ( @@ -79,16 +83,6 @@ func (r PermissionsList) Auditable() map[string]interface{} { // Fill processes request and fills internal variables func (r *PermissionsList) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } return err } @@ -112,16 +106,6 @@ func (r PermissionsEffective) GetResource() string { // Fill processes request and fills internal variables func (r *PermissionsEffective) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { // GET params @@ -157,16 +141,6 @@ func (r PermissionsRead) GetRoleID() uint64 { // Fill processes request and fills internal variables func (r *PermissionsRead) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -202,16 +176,6 @@ func (r PermissionsDelete) GetRoleID() uint64 { // Fill processes request and fills internal variables func (r *PermissionsDelete) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -253,6 +217,7 @@ func (r PermissionsUpdate) GetRules() rbac.RuleSet { // Fill processes request and fills internal variables func (r *PermissionsUpdate) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) diff --git a/compose/rest/request/record.go b/compose/rest/request/record.go index 4592cd689..43a55ea8c 100644 --- a/compose/rest/request/record.go +++ b/compose/rest/request/record.go @@ -27,6 +27,10 @@ var ( _ = chi.URLParam _ = multipart.ErrMessageTooLarge _ = payload.ParseUint64s + _ = strings.ToLower + _ = io.EOF + _ = fmt.Errorf + _ = json.NewEncoder ) type ( @@ -465,16 +469,6 @@ func (r RecordReport) GetFilter() string { // Fill processes request and fills internal variables func (r *RecordReport) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { // GET params @@ -600,16 +594,6 @@ func (r RecordList) GetSort() string { // Fill processes request and fills internal variables func (r *RecordList) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { // GET params @@ -728,6 +712,7 @@ func (r RecordImportInit) GetUpload() *multipart.FileHeader { // Fill processes request and fills internal variables func (r *RecordImportInit) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -816,6 +801,7 @@ func (r RecordImportRun) GetOnError() string { // Fill processes request and fills internal variables func (r *RecordImportRun) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -907,16 +893,6 @@ func (r RecordImportProgress) GetSessionID() uint64 { // Fill processes request and fills internal variables func (r *RecordImportProgress) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -1000,16 +976,6 @@ func (r RecordExport) GetTimezone() string { // Fill processes request and fills internal variables func (r *RecordExport) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { // GET params @@ -1110,6 +1076,7 @@ func (r RecordExec) GetArgs() []ProcedureArg { // Fill processes request and fills internal variables func (r *RecordExec) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -1206,6 +1173,7 @@ func (r RecordCreate) GetLabels() map[string]string { // Fill processes request and fills internal variables func (r *RecordCreate) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -1303,16 +1271,6 @@ func (r RecordRead) GetRecordID() uint64 { // Fill processes request and fills internal variables func (r *RecordRead) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -1390,6 +1348,7 @@ func (r RecordUpdate) GetLabels() map[string]string { // Fill processes request and fills internal variables func (r *RecordUpdate) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -1499,6 +1458,7 @@ func (r RecordBulkDelete) GetTruncate() bool { // Fill processes request and fills internal variables func (r *RecordBulkDelete) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -1584,16 +1544,6 @@ func (r RecordDelete) GetRecordID() uint64 { // Fill processes request and fills internal variables func (r *RecordDelete) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -1665,6 +1615,7 @@ func (r RecordUpload) GetUpload() *multipart.FileHeader { // Fill processes request and fills internal variables func (r *RecordUpload) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -1767,6 +1718,7 @@ func (r RecordTriggerScript) GetValues() types.RecordValueSet { // Fill processes request and fills internal variables func (r *RecordTriggerScript) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -1858,6 +1810,7 @@ func (r RecordTriggerScriptOnList) GetScript() string { // Fill processes request and fills internal variables func (r *RecordTriggerScriptOnList) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) diff --git a/federation/rest/request/manageStructure.go b/federation/rest/request/manageStructure.go index 016a0dae0..695a61caa 100644 --- a/federation/rest/request/manageStructure.go +++ b/federation/rest/request/manageStructure.go @@ -26,6 +26,10 @@ var ( _ = chi.URLParam _ = multipart.ErrMessageTooLarge _ = payload.ParseUint64s + _ = strings.ToLower + _ = io.EOF + _ = fmt.Errorf + _ = json.NewEncoder ) type ( @@ -227,16 +231,6 @@ func (r ManageStructureReadExposed) GetModuleID() uint64 { // Fill processes request and fills internal variables func (r *ManageStructureReadExposed) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -308,6 +302,7 @@ func (r ManageStructureCreateExposed) GetFields() types.ModuleFieldSet { // Fill processes request and fills internal variables func (r *ManageStructureCreateExposed) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -432,6 +427,7 @@ func (r ManageStructureUpdateExposed) GetFields() types.ModuleFieldSet { // Fill processes request and fills internal variables func (r *ManageStructureUpdateExposed) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -532,16 +528,6 @@ func (r ManageStructureRemoveExposed) GetModuleID() uint64 { // Fill processes request and fills internal variables func (r *ManageStructureRemoveExposed) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -589,16 +575,6 @@ func (r ManageStructureReadShared) GetModuleID() uint64 { // Fill processes request and fills internal variables func (r *ManageStructureReadShared) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -664,6 +640,7 @@ func (r ManageStructureCreateMappings) GetFields() types.ModuleFieldMappingSet { // Fill processes request and fills internal variables func (r *ManageStructureCreateMappings) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -756,16 +733,6 @@ func (r ManageStructureReadMappings) GetComposeModuleID() uint64 { // Fill processes request and fills internal variables func (r *ManageStructureReadMappings) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { // GET params @@ -837,16 +804,6 @@ func (r ManageStructureListAll) GetMapped() bool { // Fill processes request and fills internal variables func (r *ManageStructureListAll) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { // GET params diff --git a/federation/rest/request/node.go b/federation/rest/request/node.go index 30740a08f..73c171ece 100644 --- a/federation/rest/request/node.go +++ b/federation/rest/request/node.go @@ -25,6 +25,10 @@ var ( _ = chi.URLParam _ = multipart.ErrMessageTooLarge _ = payload.ParseUint64s + _ = strings.ToLower + _ = io.EOF + _ = fmt.Errorf + _ = json.NewEncoder ) type ( @@ -165,16 +169,6 @@ func (r NodeSearch) GetStatus() string { // Fill processes request and fills internal variables func (r *NodeSearch) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { // GET params @@ -234,6 +228,7 @@ func (r NodeCreate) GetPairingURI() string { // Fill processes request and fills internal variables func (r *NodeCreate) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -303,16 +298,6 @@ func (r NodeRead) GetNodeID() uint64 { // Fill processes request and fills internal variables func (r *NodeRead) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -348,16 +333,6 @@ func (r NodeGenerateURI) GetNodeID() uint64 { // Fill processes request and fills internal variables func (r *NodeGenerateURI) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -411,6 +386,7 @@ func (r NodeUpdate) GetBaseURL() string { // Fill processes request and fills internal variables func (r *NodeUpdate) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -485,16 +461,6 @@ func (r NodeDelete) GetNodeID() uint64 { // Fill processes request and fills internal variables func (r *NodeDelete) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -530,16 +496,6 @@ func (r NodeUndelete) GetNodeID() uint64 { // Fill processes request and fills internal variables func (r *NodeUndelete) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -575,16 +531,6 @@ func (r NodePair) GetNodeID() uint64 { // Fill processes request and fills internal variables func (r *NodePair) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -620,16 +566,6 @@ func (r NodeHandshakeConfirm) GetNodeID() uint64 { // Fill processes request and fills internal variables func (r *NodeHandshakeConfirm) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -671,6 +607,7 @@ func (r NodeHandshakeComplete) GetAuthToken() string { // Fill processes request and fills internal variables func (r *NodeHandshakeComplete) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) diff --git a/federation/rest/request/nodeHandshake.go b/federation/rest/request/nodeHandshake.go index 851f03ad0..65d3bae3f 100644 --- a/federation/rest/request/nodeHandshake.go +++ b/federation/rest/request/nodeHandshake.go @@ -25,6 +25,10 @@ var ( _ = chi.URLParam _ = multipart.ErrMessageTooLarge _ = payload.ParseUint64s + _ = strings.ToLower + _ = io.EOF + _ = fmt.Errorf + _ = json.NewEncoder ) type ( @@ -89,6 +93,7 @@ func (r NodeHandshakeInitialize) GetAuthToken() string { // Fill processes request and fills internal variables func (r *NodeHandshakeInitialize) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) diff --git a/federation/rest/request/permissions.go b/federation/rest/request/permissions.go index bbee21dd7..3241cae68 100644 --- a/federation/rest/request/permissions.go +++ b/federation/rest/request/permissions.go @@ -26,6 +26,10 @@ var ( _ = chi.URLParam _ = multipart.ErrMessageTooLarge _ = payload.ParseUint64s + _ = strings.ToLower + _ = io.EOF + _ = fmt.Errorf + _ = json.NewEncoder ) type ( @@ -79,16 +83,6 @@ func (r PermissionsList) Auditable() map[string]interface{} { // Fill processes request and fills internal variables func (r *PermissionsList) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } return err } @@ -112,16 +106,6 @@ func (r PermissionsEffective) GetResource() string { // Fill processes request and fills internal variables func (r *PermissionsEffective) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { // GET params @@ -157,16 +141,6 @@ func (r PermissionsRead) GetRoleID() uint64 { // Fill processes request and fills internal variables func (r *PermissionsRead) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -202,16 +176,6 @@ func (r PermissionsDelete) GetRoleID() uint64 { // Fill processes request and fills internal variables func (r *PermissionsDelete) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -253,6 +217,7 @@ func (r PermissionsUpdate) GetRules() rbac.RuleSet { // Fill processes request and fills internal variables func (r *PermissionsUpdate) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) diff --git a/federation/rest/request/syncData.go b/federation/rest/request/syncData.go index b02e13202..f7983195e 100644 --- a/federation/rest/request/syncData.go +++ b/federation/rest/request/syncData.go @@ -25,6 +25,10 @@ var ( _ = chi.URLParam _ = multipart.ErrMessageTooLarge _ = payload.ParseUint64s + _ = strings.ToLower + _ = io.EOF + _ = fmt.Errorf + _ = json.NewEncoder ) type ( @@ -185,16 +189,6 @@ func (r SyncDataReadExposedAll) GetSort() string { // Fill processes request and fills internal variables func (r *SyncDataReadExposedAll) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { // GET params @@ -302,16 +296,6 @@ func (r SyncDataReadExposedInternal) GetSort() string { // Fill processes request and fills internal variables func (r *SyncDataReadExposedInternal) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { // GET params @@ -425,16 +409,6 @@ func (r SyncDataReadExposedSocial) GetSort() string { // Fill processes request and fills internal variables func (r *SyncDataReadExposedSocial) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { // GET params diff --git a/federation/rest/request/syncStructure.go b/federation/rest/request/syncStructure.go index bb40fa092..1376d2a4e 100644 --- a/federation/rest/request/syncStructure.go +++ b/federation/rest/request/syncStructure.go @@ -25,6 +25,10 @@ var ( _ = chi.URLParam _ = multipart.ErrMessageTooLarge _ = payload.ParseUint64s + _ = strings.ToLower + _ = io.EOF + _ = fmt.Errorf + _ = json.NewEncoder ) type ( @@ -143,16 +147,6 @@ func (r SyncStructureReadExposedInternal) GetSort() string { // Fill processes request and fills internal variables func (r *SyncStructureReadExposedInternal) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { // GET params @@ -254,16 +248,6 @@ func (r SyncStructureReadExposedSocial) GetSort() string { // Fill processes request and fills internal variables func (r *SyncStructureReadExposedSocial) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { // GET params diff --git a/messaging/automation/dummy.go b/messaging/automation/dummy.go deleted file mode 100644 index 075d4da06..000000000 --- a/messaging/automation/dummy.go +++ /dev/null @@ -1 +0,0 @@ -package automation diff --git a/pkg/codegen/assets/rest_request.go.tpl b/pkg/codegen/assets/rest_request.go.tpl index 0506d16ab..7a54724bf 100644 --- a/pkg/codegen/assets/rest_request.go.tpl +++ b/pkg/codegen/assets/rest_request.go.tpl @@ -28,6 +28,10 @@ var ( _ = chi.URLParam _ = multipart.ErrMessageTooLarge _ = payload.ParseUint64s + _ = strings.ToLower + _ = io.EOF + _ = fmt.Errorf + _ = json.NewEncoder ) type ( @@ -72,6 +76,7 @@ func (r {{ export $.Endpoint.Entrypoint $a.Name }}) Get{{ export $p.Name }}() {{ // Fill processes request and fills internal variables func (r *{{ export $.Endpoint.Entrypoint $a.Name }}) Fill(req *http.Request) (err error) { + {{ if $a.Params.Post }} if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -82,6 +87,7 @@ func (r *{{ export $.Endpoint.Entrypoint $a.Name }}) Fill(req *http.Request) (er return fmt.Errorf("error parsing http request body: %w", err) } } + {{- end }} {{ if $a.Params.Get }} diff --git a/system/rest/request/actionlog.go b/system/rest/request/actionlog.go index d79b4825e..c5afd1664 100644 --- a/system/rest/request/actionlog.go +++ b/system/rest/request/actionlog.go @@ -26,6 +26,10 @@ var ( _ = chi.URLParam _ = multipart.ErrMessageTooLarge _ = payload.ParseUint64s + _ = strings.ToLower + _ = io.EOF + _ = fmt.Errorf + _ = json.NewEncoder ) type ( @@ -123,16 +127,6 @@ func (r ActionlogList) GetLimit() uint { // Fill processes request and fills internal variables func (r *ActionlogList) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { // GET params diff --git a/system/rest/request/application.go b/system/rest/request/application.go index bd1e4389d..a7bf84038 100644 --- a/system/rest/request/application.go +++ b/system/rest/request/application.go @@ -27,6 +27,10 @@ var ( _ = chi.URLParam _ = multipart.ErrMessageTooLarge _ = payload.ParseUint64s + _ = strings.ToLower + _ = io.EOF + _ = fmt.Errorf + _ = json.NewEncoder ) type ( @@ -301,16 +305,6 @@ func (r ApplicationList) GetSort() string { // Fill processes request and fills internal variables func (r *ApplicationList) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { // GET params @@ -434,6 +428,7 @@ func (r ApplicationCreate) GetLabels() map[string]string { // Fill processes request and fills internal variables func (r *ApplicationCreate) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -558,6 +553,7 @@ func (r ApplicationUpdate) GetLabels() map[string]string { // Fill processes request and fills internal variables func (r *ApplicationUpdate) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -658,6 +654,7 @@ func (r ApplicationUpload) GetUpload() *multipart.FileHeader { // Fill processes request and fills internal variables func (r *ApplicationUpload) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -716,16 +713,6 @@ func (r ApplicationFlagCreate) GetOwnedBy() uint64 { // Fill processes request and fills internal variables func (r *ApplicationFlagCreate) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -785,16 +772,6 @@ func (r ApplicationFlagDelete) GetOwnedBy() uint64 { // Fill processes request and fills internal variables func (r *ApplicationFlagDelete) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -848,16 +825,6 @@ func (r ApplicationRead) GetIncFlags() uint { // Fill processes request and fills internal variables func (r *ApplicationRead) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { // GET params @@ -905,16 +872,6 @@ func (r ApplicationDelete) GetApplicationID() uint64 { // Fill processes request and fills internal variables func (r *ApplicationDelete) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -950,16 +907,6 @@ func (r ApplicationUndelete) GetApplicationID() uint64 { // Fill processes request and fills internal variables func (r *ApplicationUndelete) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -1001,6 +948,7 @@ func (r ApplicationTriggerScript) GetScript() string { // Fill processes request and fills internal variables func (r *ApplicationTriggerScript) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -1061,6 +1009,7 @@ func (r ApplicationReorder) GetApplicationIDs() []string { // Fill processes request and fills internal variables func (r *ApplicationReorder) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) diff --git a/system/rest/request/attachment.go b/system/rest/request/attachment.go index ee84fc55b..92c26262c 100644 --- a/system/rest/request/attachment.go +++ b/system/rest/request/attachment.go @@ -25,6 +25,10 @@ var ( _ = chi.URLParam _ = multipart.ErrMessageTooLarge _ = payload.ParseUint64s + _ = strings.ToLower + _ = io.EOF + _ = fmt.Errorf + _ = json.NewEncoder ) type ( @@ -170,16 +174,6 @@ func (r AttachmentRead) GetUserID() uint64 { // Fill processes request and fills internal variables func (r *AttachmentRead) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { // GET params @@ -257,16 +251,6 @@ func (r AttachmentDelete) GetUserID() uint64 { // Fill processes request and fills internal variables func (r *AttachmentDelete) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { // GET params @@ -356,16 +340,6 @@ func (r AttachmentOriginal) GetDownload() bool { // Fill processes request and fills internal variables func (r *AttachmentOriginal) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { // GET params @@ -461,16 +435,6 @@ func (r AttachmentPreview) GetUserID() uint64 { // Fill processes request and fills internal variables func (r *AttachmentPreview) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { // GET params diff --git a/system/rest/request/auth.go b/system/rest/request/auth.go index f40e8a06a..ed7a7d6fb 100644 --- a/system/rest/request/auth.go +++ b/system/rest/request/auth.go @@ -25,6 +25,10 @@ var ( _ = chi.URLParam _ = multipart.ErrMessageTooLarge _ = payload.ParseUint64s + _ = strings.ToLower + _ = io.EOF + _ = fmt.Errorf + _ = json.NewEncoder ) type ( @@ -56,6 +60,7 @@ func (r AuthImpersonate) GetUserID() uint64 { // Fill processes request and fills internal variables func (r *AuthImpersonate) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) diff --git a/system/rest/request/authClient.go b/system/rest/request/authClient.go index 0e9a4cf67..880eefc94 100644 --- a/system/rest/request/authClient.go +++ b/system/rest/request/authClient.go @@ -28,6 +28,10 @@ var ( _ = chi.URLParam _ = multipart.ErrMessageTooLarge _ = payload.ParseUint64s + _ = strings.ToLower + _ = io.EOF + _ = fmt.Errorf + _ = json.NewEncoder ) type ( @@ -268,16 +272,6 @@ func (r AuthClientList) GetSort() string { // Fill processes request and fills internal variables func (r *AuthClientList) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { // GET params @@ -408,6 +402,7 @@ func (r AuthClientCreate) GetLabels() map[string]string { // Fill processes request and fills internal variables func (r *AuthClientCreate) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -607,6 +602,7 @@ func (r AuthClientUpdate) GetLabels() map[string]string { // Fill processes request and fills internal variables func (r *AuthClientUpdate) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -752,16 +748,6 @@ func (r AuthClientRead) GetClientID() uint64 { // Fill processes request and fills internal variables func (r *AuthClientRead) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -797,16 +783,6 @@ func (r AuthClientDelete) GetClientID() uint64 { // Fill processes request and fills internal variables func (r *AuthClientDelete) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -842,16 +818,6 @@ func (r AuthClientUndelete) GetClientID() uint64 { // Fill processes request and fills internal variables func (r *AuthClientUndelete) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -887,16 +853,6 @@ func (r AuthClientRegenerateSecret) GetClientID() uint64 { // Fill processes request and fills internal variables func (r *AuthClientRegenerateSecret) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -932,16 +888,6 @@ func (r AuthClientExposeSecret) GetClientID() uint64 { // Fill processes request and fills internal variables func (r *AuthClientExposeSecret) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string diff --git a/system/rest/request/automation.go b/system/rest/request/automation.go index eca3335ce..c7a1c1961 100644 --- a/system/rest/request/automation.go +++ b/system/rest/request/automation.go @@ -25,6 +25,10 @@ var ( _ = chi.URLParam _ = multipart.ErrMessageTooLarge _ = payload.ParseUint64s + _ = strings.ToLower + _ = io.EOF + _ = fmt.Errorf + _ = json.NewEncoder ) type ( @@ -135,16 +139,6 @@ func (r AutomationList) GetExcludeServerScripts() bool { // Fill processes request and fills internal variables func (r *AutomationList) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { // GET params @@ -237,16 +231,6 @@ func (r AutomationBundle) GetExt() string { // Fill processes request and fills internal variables func (r *AutomationBundle) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -294,6 +278,7 @@ func (r AutomationTriggerScript) GetScript() string { // Fill processes request and fills internal variables func (r *AutomationTriggerScript) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) diff --git a/system/rest/request/permissions.go b/system/rest/request/permissions.go index bbee21dd7..3241cae68 100644 --- a/system/rest/request/permissions.go +++ b/system/rest/request/permissions.go @@ -26,6 +26,10 @@ var ( _ = chi.URLParam _ = multipart.ErrMessageTooLarge _ = payload.ParseUint64s + _ = strings.ToLower + _ = io.EOF + _ = fmt.Errorf + _ = json.NewEncoder ) type ( @@ -79,16 +83,6 @@ func (r PermissionsList) Auditable() map[string]interface{} { // Fill processes request and fills internal variables func (r *PermissionsList) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } return err } @@ -112,16 +106,6 @@ func (r PermissionsEffective) GetResource() string { // Fill processes request and fills internal variables func (r *PermissionsEffective) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { // GET params @@ -157,16 +141,6 @@ func (r PermissionsRead) GetRoleID() uint64 { // Fill processes request and fills internal variables func (r *PermissionsRead) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -202,16 +176,6 @@ func (r PermissionsDelete) GetRoleID() uint64 { // Fill processes request and fills internal variables func (r *PermissionsDelete) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -253,6 +217,7 @@ func (r PermissionsUpdate) GetRules() rbac.RuleSet { // Fill processes request and fills internal variables func (r *PermissionsUpdate) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) diff --git a/system/rest/request/reminder.go b/system/rest/request/reminder.go index f86a7453e..bf300a892 100644 --- a/system/rest/request/reminder.go +++ b/system/rest/request/reminder.go @@ -27,6 +27,10 @@ var ( _ = chi.URLParam _ = multipart.ErrMessageTooLarge _ = payload.ParseUint64s + _ = strings.ToLower + _ = io.EOF + _ = fmt.Errorf + _ = json.NewEncoder ) type ( @@ -239,16 +243,6 @@ func (r ReminderList) GetSort() string { // Fill processes request and fills internal variables func (r *ReminderList) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { // GET params @@ -361,6 +355,7 @@ func (r ReminderCreate) GetRemindAt() *time.Time { // Fill processes request and fills internal variables func (r *ReminderCreate) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -454,6 +449,7 @@ func (r ReminderUpdate) GetRemindAt() *time.Time { // Fill processes request and fills internal variables func (r *ReminderUpdate) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -535,16 +531,6 @@ func (r ReminderRead) GetReminderID() uint64 { // Fill processes request and fills internal variables func (r *ReminderRead) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -580,16 +566,6 @@ func (r ReminderDelete) GetReminderID() uint64 { // Fill processes request and fills internal variables func (r *ReminderDelete) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -625,16 +601,6 @@ func (r ReminderDismiss) GetReminderID() uint64 { // Fill processes request and fills internal variables func (r *ReminderDismiss) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -676,6 +642,7 @@ func (r ReminderSnooze) GetRemindAt() *time.Time { // Fill processes request and fills internal variables func (r *ReminderSnooze) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) diff --git a/system/rest/request/role.go b/system/rest/request/role.go index f91206f67..44ba8d397 100644 --- a/system/rest/request/role.go +++ b/system/rest/request/role.go @@ -26,6 +26,10 @@ var ( _ = chi.URLParam _ = multipart.ErrMessageTooLarge _ = payload.ParseUint64s + _ = strings.ToLower + _ = io.EOF + _ = fmt.Errorf + _ = json.NewEncoder ) type ( @@ -274,16 +278,6 @@ func (r RoleList) GetSort() string { // Fill processes request and fills internal variables func (r *RoleList) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { // GET params @@ -378,6 +372,7 @@ func (r RoleCreate) GetLabels() map[string]string { // Fill processes request and fills internal variables func (r *RoleCreate) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -476,6 +471,7 @@ func (r RoleUpdate) GetLabels() map[string]string { // Fill processes request and fills internal variables func (r *RoleUpdate) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -562,16 +558,6 @@ func (r RoleRead) GetRoleID() uint64 { // Fill processes request and fills internal variables func (r *RoleRead) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -607,16 +593,6 @@ func (r RoleDelete) GetRoleID() uint64 { // Fill processes request and fills internal variables func (r *RoleDelete) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -652,16 +628,6 @@ func (r RoleArchive) GetRoleID() uint64 { // Fill processes request and fills internal variables func (r *RoleArchive) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -697,16 +663,6 @@ func (r RoleUnarchive) GetRoleID() uint64 { // Fill processes request and fills internal variables func (r *RoleUnarchive) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -742,16 +698,6 @@ func (r RoleUndelete) GetRoleID() uint64 { // Fill processes request and fills internal variables func (r *RoleUndelete) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -793,6 +739,7 @@ func (r RoleMove) GetOrganisationID() uint64 { // Fill processes request and fills internal variables func (r *RoleMove) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -859,6 +806,7 @@ func (r RoleMerge) GetDestination() uint64 { // Fill processes request and fills internal variables func (r *RoleMerge) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -919,16 +867,6 @@ func (r RoleMemberList) GetRoleID() uint64 { // Fill processes request and fills internal variables func (r *RoleMemberList) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -970,16 +908,6 @@ func (r RoleMemberAdd) GetUserID() uint64 { // Fill processes request and fills internal variables func (r *RoleMemberAdd) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -1027,16 +955,6 @@ func (r RoleMemberRemove) GetUserID() uint64 { // Fill processes request and fills internal variables func (r *RoleMemberRemove) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -1084,6 +1002,7 @@ func (r RoleTriggerScript) GetScript() string { // Fill processes request and fills internal variables func (r *RoleTriggerScript) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) diff --git a/system/rest/request/settings.go b/system/rest/request/settings.go index 1d2d904ab..e92bc9e98 100644 --- a/system/rest/request/settings.go +++ b/system/rest/request/settings.go @@ -26,6 +26,10 @@ var ( _ = chi.URLParam _ = multipart.ErrMessageTooLarge _ = payload.ParseUint64s + _ = strings.ToLower + _ = io.EOF + _ = fmt.Errorf + _ = json.NewEncoder ) type ( @@ -96,16 +100,6 @@ func (r SettingsList) GetPrefix() string { // Fill processes request and fills internal variables func (r *SettingsList) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { // GET params @@ -141,6 +135,7 @@ func (r SettingsUpdate) GetValues() types.SettingValueSet { // Fill processes request and fills internal variables func (r *SettingsUpdate) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -195,16 +190,6 @@ func (r SettingsGet) GetOwnerID() uint64 { // Fill processes request and fills internal variables func (r *SettingsGet) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { // GET params @@ -264,6 +249,7 @@ func (r SettingsSet) GetOwnerID() uint64 { // Fill processes request and fills internal variables func (r *SettingsSet) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -321,16 +307,6 @@ func (r SettingsCurrent) Auditable() map[string]interface{} { // Fill processes request and fills internal variables func (r *SettingsCurrent) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } return err } diff --git a/system/rest/request/stats.go b/system/rest/request/stats.go index 0ed9faaf5..f9b93b6d5 100644 --- a/system/rest/request/stats.go +++ b/system/rest/request/stats.go @@ -25,6 +25,10 @@ var ( _ = chi.URLParam _ = multipart.ErrMessageTooLarge _ = payload.ParseUint64s + _ = strings.ToLower + _ = io.EOF + _ = fmt.Errorf + _ = json.NewEncoder ) type ( @@ -45,16 +49,6 @@ func (r StatsList) Auditable() map[string]interface{} { // Fill processes request and fills internal variables func (r *StatsList) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } return err } diff --git a/system/rest/request/template.go b/system/rest/request/template.go index 77ee2ef79..fb6c644fc 100644 --- a/system/rest/request/template.go +++ b/system/rest/request/template.go @@ -27,6 +27,10 @@ var ( _ = chi.URLParam _ = multipart.ErrMessageTooLarge _ = payload.ParseUint64s + _ = strings.ToLower + _ = io.EOF + _ = fmt.Errorf + _ = json.NewEncoder ) type ( @@ -283,16 +287,6 @@ func (r TemplateList) GetSort() string { // Fill processes request and fills internal variables func (r *TemplateList) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { // GET params @@ -423,6 +417,7 @@ func (r TemplateCreate) GetLabels() map[string]string { // Fill processes request and fills internal variables func (r *TemplateCreate) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -530,16 +525,6 @@ func (r TemplateRead) GetTemplateID() uint64 { // Fill processes request and fills internal variables func (r *TemplateRead) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -623,6 +608,7 @@ func (r TemplateUpdate) GetLabels() map[string]string { // Fill processes request and fills internal variables func (r *TemplateUpdate) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -742,16 +728,6 @@ func (r TemplateDelete) GetTemplateID() uint64 { // Fill processes request and fills internal variables func (r *TemplateDelete) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -787,16 +763,6 @@ func (r TemplateUndelete) GetTemplateID() uint64 { // Fill processes request and fills internal variables func (r *TemplateUndelete) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -856,6 +822,7 @@ func (r TemplateRender) GetOptions() json.RawMessage { // Fill processes request and fills internal variables func (r *TemplateRender) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) diff --git a/system/rest/request/user.go b/system/rest/request/user.go index 4e0623ded..5f711b809 100644 --- a/system/rest/request/user.go +++ b/system/rest/request/user.go @@ -27,6 +27,10 @@ var ( _ = chi.URLParam _ = multipart.ErrMessageTooLarge _ = payload.ParseUint64s + _ = strings.ToLower + _ = io.EOF + _ = fmt.Errorf + _ = json.NewEncoder ) type ( @@ -368,16 +372,6 @@ func (r UserList) GetSort() string { // Fill processes request and fills internal variables func (r *UserList) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { // GET params @@ -536,6 +530,7 @@ func (r UserCreate) GetLabels() map[string]string { // Fill processes request and fills internal variables func (r *UserCreate) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -647,6 +642,7 @@ func (r UserUpdate) GetLabels() map[string]string { // Fill processes request and fills internal variables func (r *UserUpdate) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -740,16 +736,6 @@ func (r UserPartialUpdate) GetUserID() uint64 { // Fill processes request and fills internal variables func (r *UserPartialUpdate) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -785,16 +771,6 @@ func (r UserRead) GetUserID() uint64 { // Fill processes request and fills internal variables func (r *UserRead) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -830,16 +806,6 @@ func (r UserDelete) GetUserID() uint64 { // Fill processes request and fills internal variables func (r *UserDelete) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -875,16 +841,6 @@ func (r UserSuspend) GetUserID() uint64 { // Fill processes request and fills internal variables func (r *UserSuspend) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -920,16 +876,6 @@ func (r UserUnsuspend) GetUserID() uint64 { // Fill processes request and fills internal variables func (r *UserUnsuspend) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -965,16 +911,6 @@ func (r UserUndelete) GetUserID() uint64 { // Fill processes request and fills internal variables func (r *UserUndelete) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -1015,6 +951,7 @@ func (r UserSetPassword) GetPassword() string { // Fill processes request and fills internal variables func (r *UserSetPassword) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r) @@ -1075,16 +1012,6 @@ func (r UserMembershipList) GetUserID() uint64 { // Fill processes request and fills internal variables func (r *UserMembershipList) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -1126,16 +1053,6 @@ func (r UserMembershipAdd) GetUserID() uint64 { // Fill processes request and fills internal variables func (r *UserMembershipAdd) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -1183,16 +1100,6 @@ func (r UserMembershipRemove) GetUserID() uint64 { // Fill processes request and fills internal variables func (r *UserMembershipRemove) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { - err = json.NewDecoder(req.Body).Decode(r) - - switch { - case err == io.EOF: - err = nil - case err != nil: - return fmt.Errorf("error parsing http request body: %w", err) - } - } { var val string @@ -1240,6 +1147,7 @@ func (r UserTriggerScript) GetScript() string { // Fill processes request and fills internal variables func (r *UserTriggerScript) Fill(req *http.Request) (err error) { + if strings.ToLower(req.Header.Get("content-type")) == "application/json" { err = json.NewDecoder(req.Body).Decode(r)