3
0

Do not decode JSON from body if no POST params are spec.

This commit is contained in:
Denis Arh
2021-03-08 17:42:16 +01:00
parent 186b6cb99e
commit 82c76bbe6c
37 changed files with 214 additions and 1261 deletions
+7 -50
View File
@@ -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
+7 -70
View File
@@ -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)
+5
View File
@@ -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)
+5 -40
View File
@@ -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)
+4 -30
View File
@@ -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
+4 -20
View File
@@ -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