Skip to content

feat: support {:form,data} tagged body tuples#886

Merged
yordis merged 1 commit into
elixir-tesla:masterfrom
tsitsiridakisiosif:feat/tagged-form-body-tupl
Jun 5, 2026
Merged

feat: support {:form,data} tagged body tuples#886
yordis merged 1 commit into
elixir-tesla:masterfrom
tsitsiridakisiosif:feat/tagged-form-body-tupl

Conversation

@tsitsiridakisiosif

Copy link
Copy Markdown
Contributor

No description provided.

@cursor

cursor Bot commented Jun 4, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Small, targeted middleware encoding rules with tests; no auth or data-layer changes, and existing untagged body behavior is preserved.

Overview
Adds an explicit {:form_urlencoded, data} request body tag so callers can force URL-encoded encoding when a client stacks JSON and FormUrlencoded middleware (where a bare map would otherwise be JSON-encoded).

FormUrlencoded now treats tagged bodies as encodable, unwraps the inner data for encoding (including existing :brackets / custom encode options), and sets application/x-www-form-urlencoded. JSON skips tagged bodies entirely—no JSON encoding and no application/json header—leaving them for the form middleware. Untagged map bodies behave as before.

Tests cover default and bracket encoding for tagged tuples, JSON pass-through, and backward compatibility for plain maps.

Reviewed by Cursor Bugbot for commit afd620a. Bugbot is set up for automated code reviews on this repo. Configure here.

Comment thread lib/tesla/middleware/form_urlencoded.ex Outdated
end
end

defp encodable?(%{body: {:form, _}}), do: true

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should the name be :form_urlencoded?

@tsitsiridakisiosif tsitsiridakisiosif force-pushed the feat/tagged-form-body-tupl branch from 7ec2e71 to afd620a Compare June 5, 2026 07:34
@yordis yordis merged commit b1b3b80 into elixir-tesla:master Jun 5, 2026
7 of 8 checks passed
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