Support x-www-form-urlencoded form-data

This commit is contained in:
Mike Schwörer 2023-06-18 03:46:01 +02:00
parent 860e540de1
commit c46190c3fc
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
2 changed files with 5 additions and 0 deletions

View File

@ -15,6 +15,7 @@
- app-store link in HTML - app-store link in HTML
- deploy - deploy
- deploy apache conf directly
- backups (no longer container in my db_backup, perhaps extend it to sqlite?) - backups (no longer container in my db_backup, perhaps extend it to sqlite?)

View File

@ -263,6 +263,10 @@ func (app *Application) StartRequest(g *gin.Context, uri any, query any, body an
if err := g.ShouldBindWith(form, binding.Form); err != nil { if err := g.ShouldBindWith(form, binding.Form); err != nil {
return nil, langext.Ptr(ginresp.APIError(g, 400, apierr.BINDFAIL_BODY_PARAM, "Failed to read multipart-form", err)) return nil, langext.Ptr(ginresp.APIError(g, 400, apierr.BINDFAIL_BODY_PARAM, "Failed to read multipart-form", err))
} }
} else if g.ContentType() == "application/x-www-form-urlencoded" {
if err := g.ShouldBindWith(form, binding.Form); err != nil {
return nil, langext.Ptr(ginresp.APIError(g, 400, apierr.BINDFAIL_BODY_PARAM, "Failed to read urlencoded-form", err))
}
} else { } else {
if !ignoreWrongContentType { if !ignoreWrongContentType {
return nil, langext.Ptr(ginresp.APIError(g, 400, apierr.BINDFAIL_BODY_PARAM, "missing form body", nil)) return nil, langext.Ptr(ginresp.APIError(g, 400, apierr.BINDFAIL_BODY_PARAM, "missing form body", nil))