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 BodyMultipart #119

Merged
merged 2 commits into from
Nov 21, 2024
Merged

Add BodyMultipart #119

merged 2 commits into from
Nov 21, 2024

Conversation

earthboundkid
Copy link
Owner

No description provided.

@coveralls
Copy link

coveralls commented Aug 27, 2024

Pull Request Test Coverage Report for Build 11958952365

Details

  • 11 of 20 (55.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.8%) to 90.779%

Changes Missing Coverage Covered Lines Changed/Added Lines %
config.go 11 20 55.0%
Totals Coverage Status
Change from base Build 10584845958: -0.8%
Covered Lines: 827
Relevant Lines: 911

💛 - Coveralls

@Crocmagnon
Copy link

Crocmagnon commented Aug 27, 2024

Nice! 🎉

Would it be possible to make it available as well as a method directly on *Builder if that makes sense? I imagined something like this, similar to the Body* methods:

requests.URL("https://example.com").
    BodyMultipart("boundary", func(multi *multipart.Writer) error {
        // do something with multi
        return nil
    }).
    Fetch(ctx)

@earthboundkid
Copy link
Owner Author

Do you think there's that much demand for it? OTOH, nesting the Config calls looks pretty ugly. Also unlike some of the other stuff I'm trying to move out to separate packages, this imports mime/multipart, which net/http also imports, so it's not introducing any import dependencies. 🤔

@earthboundkid
Copy link
Owner Author

There's some weirdness around the random boundary. I think if you created a Builder and reused it, you would get the same "random" boundary every time until you make a new Builder. That's probably an okay limitation for a Config, but for a method I would expect it to work every time…

@Crocmagnon
Copy link

Crocmagnon commented Aug 27, 2024

Do you think there's that much demand for it?

Probably not, seeing the activity about the topic in the discussion 😛.
My concern is mostly about discoverability, I wasn't aware of Config before your PR.
For this kind of "simple" HTTP usage, I'd be in favor of consistency in the API.

nesting the Config calls looks pretty ugly.

Agreed.

I think if you created a Builder and reused it, you would get the same "random" boundary every time until you make a new Builder.

Is it an issue? If the generated boundary is sufficiently random and is already OK for a single usage, I'm guessing that it can be safely reused. There's no requirement for it to change on every request as far as I'm aware of.

@earthboundkid earthboundkid changed the title Add Multipart Add BodyMultipart Sep 4, 2024
@Crocmagnon
Copy link

Hello! Any blocker here? Can I help releasing this? :)

@earthboundkid
Copy link
Owner Author

This looks pretty good. I think it can be released as just a config for now and we can decide if it should be promoted to a method later. I want to change the example test to use a content type for en.txt, but other than that it looks good to go.

@earthboundkid earthboundkid merged commit ed53f99 into main Nov 21, 2024
4 checks passed
@earthboundkid earthboundkid deleted the cj/multi branch November 21, 2024 18:00
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.

3 participants