From 4b113af9cca25a9d490cfb6bd87a72ef0e7e2460 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toma=C5=BE=20Jerman?= Date: Mon, 17 Jan 2022 09:21:29 +0100 Subject: [PATCH] Allow content-type header to specify the charset --- automation/rest/request/permissions.go | 2 +- automation/rest/request/session.go | 2 +- automation/rest/request/trigger.go | 4 ++-- automation/rest/request/workflow.go | 8 ++++---- compose/rest/request/automation.go | 2 +- compose/rest/request/chart.go | 4 ++-- compose/rest/request/module.go | 8 ++++---- compose/rest/request/namespace.go | 16 ++++++++-------- compose/rest/request/notification.go | 2 +- compose/rest/request/page.go | 12 ++++++------ compose/rest/request/permissions.go | 2 +- compose/rest/request/record.go | 18 +++++++++--------- federation/rest/request/manageStructure.go | 6 +++--- federation/rest/request/node.go | 6 +++--- federation/rest/request/nodeHandshake.go | 2 +- federation/rest/request/permissions.go | 2 +- pkg/codegen/assets/rest_request.go.tpl | 2 +- system/rest/request/apigwFilter.go | 4 ++-- system/rest/request/apigwRoute.go | 4 ++-- system/rest/request/application.go | 10 +++++----- system/rest/request/auth.go | 2 +- system/rest/request/authClient.go | 4 ++-- system/rest/request/automation.go | 2 +- system/rest/request/locale.go | 4 ++-- system/rest/request/permissions.go | 2 +- system/rest/request/queues.go | 4 ++-- system/rest/request/reminder.go | 6 +++--- system/rest/request/report.go | 8 ++++---- system/rest/request/role.go | 10 +++++----- system/rest/request/settings.go | 4 ++-- system/rest/request/template.go | 6 +++--- system/rest/request/user.go | 8 ++++---- 32 files changed, 88 insertions(+), 88 deletions(-) diff --git a/automation/rest/request/permissions.go b/automation/rest/request/permissions.go index 37f567241..378eb2737 100644 --- a/automation/rest/request/permissions.go +++ b/automation/rest/request/permissions.go @@ -218,7 +218,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { diff --git a/automation/rest/request/session.go b/automation/rest/request/session.go index cd0101150..526ccf9d9 100644 --- a/automation/rest/request/session.go +++ b/automation/rest/request/session.go @@ -457,7 +457,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { diff --git a/automation/rest/request/trigger.go b/automation/rest/request/trigger.go index 24ca2427b..42264ab7a 100644 --- a/automation/rest/request/trigger.go +++ b/automation/rest/request/trigger.go @@ -468,7 +468,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -759,7 +759,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { diff --git a/automation/rest/request/workflow.go b/automation/rest/request/workflow.go index ea87cb0ce..bc8109e8a 100644 --- a/automation/rest/request/workflow.go +++ b/automation/rest/request/workflow.go @@ -477,7 +477,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -798,7 +798,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -1182,7 +1182,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -1313,7 +1313,7 @@ func (r WorkflowExec) GetAsync() bool { // Fill processes request and fills internal variables func (r *WorkflowExec) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { diff --git a/compose/rest/request/automation.go b/compose/rest/request/automation.go index afdd20622..654182fe2 100644 --- a/compose/rest/request/automation.go +++ b/compose/rest/request/automation.go @@ -290,7 +290,7 @@ func (r AutomationTriggerScript) GetArgs() map[string]interface{} { // 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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { diff --git a/compose/rest/request/chart.go b/compose/rest/request/chart.go index a4c52f933..9fcb13279 100644 --- a/compose/rest/request/chart.go +++ b/compose/rest/request/chart.go @@ -324,7 +324,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -536,7 +536,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { diff --git a/compose/rest/request/module.go b/compose/rest/request/module.go index acfe84113..dbe63b768 100644 --- a/compose/rest/request/module.go +++ b/compose/rest/request/module.go @@ -410,7 +410,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -635,7 +635,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -856,7 +856,7 @@ func (r ModuleTriggerScript) GetArgs() map[string]interface{} { // 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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -1022,7 +1022,7 @@ func (r ModuleUpdateTranslations) GetTranslations() locale.ResourceTranslationSe // Fill processes request and fills internal variables func (r *ModuleUpdateTranslations) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { diff --git a/compose/rest/request/namespace.go b/compose/rest/request/namespace.go index 50d4882b8..d8d190339 100644 --- a/compose/rest/request/namespace.go +++ b/compose/rest/request/namespace.go @@ -393,7 +393,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -595,7 +595,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -787,7 +787,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -857,7 +857,7 @@ func (r NamespaceClone) GetSlug() string { // Fill processes request and fills internal variables func (r *NamespaceClone) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -1007,7 +1007,7 @@ func (r NamespaceImportInit) GetUpload() *multipart.FileHeader { // Fill processes request and fills internal variables func (r *NamespaceImportInit) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -1077,7 +1077,7 @@ func (r NamespaceImportRun) GetSlug() string { // Fill processes request and fills internal variables func (r *NamespaceImportRun) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -1180,7 +1180,7 @@ func (r NamespaceTriggerScript) GetArgs() map[string]interface{} { // 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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -1322,7 +1322,7 @@ func (r NamespaceUpdateTranslations) GetTranslations() locale.ResourceTranslatio // Fill processes request and fills internal variables func (r *NamespaceUpdateTranslations) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { diff --git a/compose/rest/request/notification.go b/compose/rest/request/notification.go index e3f09f754..05d88e115 100644 --- a/compose/rest/request/notification.go +++ b/compose/rest/request/notification.go @@ -117,7 +117,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { diff --git a/compose/rest/request/page.go b/compose/rest/request/page.go index cbabf1240..4d5fe95ec 100644 --- a/compose/rest/request/page.go +++ b/compose/rest/request/page.go @@ -525,7 +525,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -866,7 +866,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -1083,7 +1083,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -1219,7 +1219,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -1313,7 +1313,7 @@ func (r PageTriggerScript) GetArgs() map[string]interface{} { // 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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -1479,7 +1479,7 @@ func (r PageUpdateTranslations) GetTranslations() locale.ResourceTranslationSet // Fill processes request and fills internal variables func (r *PageUpdateTranslations) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { diff --git a/compose/rest/request/permissions.go b/compose/rest/request/permissions.go index 37f567241..378eb2737 100644 --- a/compose/rest/request/permissions.go +++ b/compose/rest/request/permissions.go @@ -218,7 +218,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { diff --git a/compose/rest/request/record.go b/compose/rest/request/record.go index 138b36c00..1448e136e 100644 --- a/compose/rest/request/record.go +++ b/compose/rest/request/record.go @@ -701,7 +701,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -801,7 +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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -1099,7 +1099,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -1206,7 +1206,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -1402,7 +1402,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -1533,7 +1533,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -1706,7 +1706,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -1834,7 +1834,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -1949,7 +1949,7 @@ func (r RecordTriggerScriptOnList) GetArgs() map[string]interface{} { // 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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { diff --git a/federation/rest/request/manageStructure.go b/federation/rest/request/manageStructure.go index 4695198a8..e18ea154d 100644 --- a/federation/rest/request/manageStructure.go +++ b/federation/rest/request/manageStructure.go @@ -303,7 +303,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -466,7 +466,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -717,7 +717,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { diff --git a/federation/rest/request/node.go b/federation/rest/request/node.go index 8ed27be62..a70d6314a 100644 --- a/federation/rest/request/node.go +++ b/federation/rest/request/node.go @@ -229,7 +229,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -424,7 +424,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -675,7 +675,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { diff --git a/federation/rest/request/nodeHandshake.go b/federation/rest/request/nodeHandshake.go index 5b51f1cef..75db70df8 100644 --- a/federation/rest/request/nodeHandshake.go +++ b/federation/rest/request/nodeHandshake.go @@ -94,7 +94,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { diff --git a/federation/rest/request/permissions.go b/federation/rest/request/permissions.go index 37f567241..378eb2737 100644 --- a/federation/rest/request/permissions.go +++ b/federation/rest/request/permissions.go @@ -218,7 +218,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { diff --git a/pkg/codegen/assets/rest_request.go.tpl b/pkg/codegen/assets/rest_request.go.tpl index 338f9cb04..f41a133af 100644 --- a/pkg/codegen/assets/rest_request.go.tpl +++ b/pkg/codegen/assets/rest_request.go.tpl @@ -77,7 +77,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { diff --git a/system/rest/request/apigwFilter.go b/system/rest/request/apigwFilter.go index a130fde7e..b50e51c71 100644 --- a/system/rest/request/apigwFilter.go +++ b/system/rest/request/apigwFilter.go @@ -312,7 +312,7 @@ func (r ApigwFilterCreate) GetParams() types.ApigwFilterParams { // Fill processes request and fills internal variables func (r *ApigwFilterCreate) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -493,7 +493,7 @@ func (r ApigwFilterUpdate) GetParams() types.ApigwFilterParams { // Fill processes request and fills internal variables func (r *ApigwFilterUpdate) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { diff --git a/system/rest/request/apigwRoute.go b/system/rest/request/apigwRoute.go index 77bc59cc9..d1ce4cbbf 100644 --- a/system/rest/request/apigwRoute.go +++ b/system/rest/request/apigwRoute.go @@ -331,7 +331,7 @@ func (r ApigwRouteCreate) GetMeta() types.ApigwRouteMeta { // Fill processes request and fills internal variables func (r *ApigwRouteCreate) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -492,7 +492,7 @@ func (r ApigwRouteUpdate) GetMeta() types.ApigwRouteMeta { // Fill processes request and fills internal variables func (r *ApigwRouteUpdate) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { diff --git a/system/rest/request/application.go b/system/rest/request/application.go index b7094d03a..598cde4ee 100644 --- a/system/rest/request/application.go +++ b/system/rest/request/application.go @@ -434,7 +434,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -615,7 +615,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -772,7 +772,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -1083,7 +1083,7 @@ func (r ApplicationTriggerScript) GetArgs() map[string]interface{} { // 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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -1184,7 +1184,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { diff --git a/system/rest/request/auth.go b/system/rest/request/auth.go index 372eebeab..7c9fb55c8 100644 --- a/system/rest/request/auth.go +++ b/system/rest/request/auth.go @@ -61,7 +61,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { diff --git a/system/rest/request/authClient.go b/system/rest/request/authClient.go index a04a6ff28..2808794b6 100644 --- a/system/rest/request/authClient.go +++ b/system/rest/request/authClient.go @@ -403,7 +403,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -704,7 +704,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { diff --git a/system/rest/request/automation.go b/system/rest/request/automation.go index afdd20622..654182fe2 100644 --- a/system/rest/request/automation.go +++ b/system/rest/request/automation.go @@ -290,7 +290,7 @@ func (r AutomationTriggerScript) GetArgs() map[string]interface{} { // 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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { diff --git a/system/rest/request/locale.go b/system/rest/request/locale.go index deae1ff72..2798b8b1a 100644 --- a/system/rest/request/locale.go +++ b/system/rest/request/locale.go @@ -350,7 +350,7 @@ func (r LocaleCreateResource) GetOwnerID() uint64 { // Fill processes request and fills internal variables func (r *LocaleCreateResource) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -521,7 +521,7 @@ func (r LocaleUpdateResource) GetOwnerID() uint64 { // Fill processes request and fills internal variables func (r *LocaleUpdateResource) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { diff --git a/system/rest/request/permissions.go b/system/rest/request/permissions.go index 2afb631e6..c2432bb2d 100644 --- a/system/rest/request/permissions.go +++ b/system/rest/request/permissions.go @@ -230,7 +230,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { diff --git a/system/rest/request/queues.go b/system/rest/request/queues.go index f68511a28..20a3bcbae 100644 --- a/system/rest/request/queues.go +++ b/system/rest/request/queues.go @@ -237,7 +237,7 @@ func (r QueuesCreate) GetMeta() types.QueueMeta { // Fill processes request and fills internal variables func (r *QueuesCreate) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -393,7 +393,7 @@ func (r QueuesUpdate) GetMeta() types.QueueMeta { // Fill processes request and fills internal variables func (r *QueuesUpdate) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { diff --git a/system/rest/request/reminder.go b/system/rest/request/reminder.go index e8bfdda41..819a15fed 100644 --- a/system/rest/request/reminder.go +++ b/system/rest/request/reminder.go @@ -373,7 +373,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -504,7 +504,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -734,7 +734,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { diff --git a/system/rest/request/report.go b/system/rest/request/report.go index e635409ad..b26640c3b 100644 --- a/system/rest/request/report.go +++ b/system/rest/request/report.go @@ -338,7 +338,7 @@ func (r ReportCreate) GetLabels() map[string]string { // Fill processes request and fills internal variables func (r *ReportCreate) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -508,7 +508,7 @@ func (r ReportUpdate) GetLabels() map[string]string { // Fill processes request and fills internal variables func (r *ReportUpdate) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -771,7 +771,7 @@ func (r ReportDescribe) GetDescribe() []string { // Fill processes request and fills internal variables func (r *ReportDescribe) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -850,7 +850,7 @@ func (r ReportRun) GetFrames() report.FrameDefinitionSet { // Fill processes request and fills internal variables func (r *ReportRun) Fill(req *http.Request) (err error) { - if strings.ToLower(req.Header.Get("content-type")) == "application/json" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { diff --git a/system/rest/request/role.go b/system/rest/request/role.go index 89572baf8..2f0f938cd 100644 --- a/system/rest/request/role.go +++ b/system/rest/request/role.go @@ -412,7 +412,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -576,7 +576,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -903,7 +903,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -986,7 +986,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -1204,7 +1204,7 @@ func (r RoleTriggerScript) GetArgs() map[string]interface{} { // 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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { diff --git a/system/rest/request/settings.go b/system/rest/request/settings.go index 9ca09ba3a..2ef1f648e 100644 --- a/system/rest/request/settings.go +++ b/system/rest/request/settings.go @@ -136,7 +136,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -260,7 +260,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { diff --git a/system/rest/request/template.go b/system/rest/request/template.go index 2f8907bb5..3aa6d3336 100644 --- a/system/rest/request/template.go +++ b/system/rest/request/template.go @@ -421,7 +421,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -687,7 +687,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -992,7 +992,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { diff --git a/system/rest/request/user.go b/system/rest/request/user.go index ab06f289c..5b1c96266 100644 --- a/system/rest/request/user.go +++ b/system/rest/request/user.go @@ -543,7 +543,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -704,7 +704,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -1062,7 +1062,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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch { @@ -1280,7 +1280,7 @@ func (r UserTriggerScript) GetArgs() map[string]interface{} { // 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" { + if strings.HasPrefix(strings.ToLower(req.Header.Get("content-type")), "application/json") { err = json.NewDecoder(req.Body).Decode(r) switch {