Skip to content
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

Add HAL-FORMS encoders for uri-list, form-data & x-www-form-urlencoded #42

Merged
merged 7 commits into from
Mar 28, 2024

Conversation

vierbergenlars
Copy link
Member

@vierbergenlars vierbergenlars commented Mar 25, 2024

  1. Add check that encoder supports all HAL-FORM field types
    Most encoders do not actually support encoding files; so instead of creating a broken JSON object or omitting the field, immediately fail while selecting the encoder, so failure is not dependent on the user-entered data
  2. Test that the json encoder sets the requested content-type header in the HAL-FORMS template, instead of application/json
  3. Add HalFormValues#valueMap: A shortcut to retrieve an object simply mapping propertyName to the value directly
  4. Make using HalFormsCodec#encode() easier by allowing HalFormValues or its valueMap being passed.
  5. Add form and uri-list encoders
  6. Add encoding GET requests

The JSON encoder can't handle file uploads; instead of creating a
clobbered JSON object (or omitting the field) if there is a file field present,
immediately fail when selecting the encoder.
An encoder can be registered for multiple content types; ensure
that the content-type that was actually set on the HAL-FORMS template is
sent in the request.
Adding a shortcut method to retrieve an object containing propertyName->value mappings directly
Instead of needing use HalFormValues#values to retrieve an object
suitable for encoding, accept the HalFormValues directly.

For convenience (at the cost of some type-checking), it's also allowed
to pass the values as a HalFormValuesMap object directly
For HAL-FORMS templates with method set to GET (or HEAD); we can't send
any body, but need to send the request as query parameters instead.

We can only encode to the application/x-www-form-urlencoded content type
like this, because a query string is actually that encoding; but in the
URL instead of inside the request body.
@vierbergenlars vierbergenlars merged commit 804a4dc into main Mar 28, 2024
2 checks passed
@vierbergenlars vierbergenlars deleted the more-encoders branch March 28, 2024 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants