-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better WWW form data support #477
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅ ✅ All tests successful. No failed tests found.
Flags with carried forward coverage won't be shown. Click here to find out more.
📢 Thoughts on this report? Let us know! |
rescue ex : JSON::ParseException | ASR::Exception::DeserializationException | ||
raise ATH::Exception::BadRequest.new "Malformed JSON payload.", cause: ex | ||
rescue ex : URI::SerializableError | ||
raise ATH::Exception::BadRequest.new "Malformed www form data payload.", cause: ex |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and the other are technically wrong as this error is only raised when the underlying data is missing a required property. But I'm going to leave it and just address this more holistically as part of #290.
* Leverage `URI::Params::Serializable` to handle form data request body resolution * Add `ATHA::MapQueryString` to map a request's query string into a DTO type * Add `ATH::Request#content_type_format` to return the request format's name from `content-type` header
Context
#426 refactored how query parameters are resolved for a controller action, it only handles one-off params. You might notice yourself adding the same parameters to your actions over and over. This PR expands on the last one by introducing a new
ATHA::MapQueryString
annotation which works similarly toATHA::MapRequestBody
, but for the query string of a request.This effectively allows you to use the same DTO pattern for query params as you can request bodies. This PR also allows resolving WWW form data into a DTO as well via
URI::Params::Serializable
.Changelog
ATHA::MapQueryString
to map a request's query string into a DTO typeapplication/x-www-form-urlencoded
bodies viaATHA::MapRequestBody
ATH::Request#content_type_format
to return the request format's name fromcontent-type
headerBefore merging, remember to add the
athena-framework/athena
prefix to the PR number in the PR title