Add Finch HTTP client and make hackney an optional dependency#151
Open
klacointe wants to merge 1 commit into
Open
Add Finch HTTP client and make hackney an optional dependency#151klacointe wants to merge 1 commit into
klacointe wants to merge 1 commit into
Conversation
1af66b8 to
8b3cc7a
Compare
- Add Waffle.HTTPClient.Finch, ported from the closed elixir-waffle#148 (already survived two rounds of review there), guarded with Code.ensure_loaded?(Finch) so it compiles out when finch isn't a dep - Make :hackney optional: true; guard Waffle.HTTPClient.Hackney with Code.ensure_loaded?(:hackney) and raise a clear, actionable error if it's the (default) configured client but the dependency is missing - Extract parse_content_disposition/1 onto the Waffle.HTTPClient behaviour so both clients (and custom implementations) share one parser instead of Hackney depending on the internal :hackney_headers module - Bump CI's Dockerfile to elixir:1.17-alpine (finch requires ~> 1.15) - Bump credo to ~> 1.7; ~> 1.4's tokenizer crashes under Elixir 1.17+ - Add @moduledoc false to Mix.Tasks.Waffle; credo 1.7 newly flags it as missing, unlike 1.6 - Update README/CHANGELOG to document both clients and the "at least one is required" dependency story
8b3cc7a to
58a4d41
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #150. Revives the Finch client from the closed #148 (which was split up to keep that PR scoped to the adapter pattern), and completes the original goal: making
:hackneyan optional dependency now that a real alternative exists.Waffle.HTTPClient.Finch, guarded withCode.ensure_loaded?(Finch)— the implementation is carried over unchanged from Add pluggable HTTP client behaviour with Hackney and Finch implementations #148.:hackneyoptional: true. Since it remains the default configured client,Waffle.HTTPClient.Hackneyis still always defined, but guarded withCode.ensure_loaded?(:hackney); if it's missing, calling it raises a clear, actionable error instead of a bareUndefinedFunctionError.parse_content_disposition/1onto theWaffle.HTTPClientbehaviour so both clients (and any custom implementation) share one parser, instead ofHackneydepending on the internal:hackney_headersmodule.Dockerfiletoelixir:1.17-alpine(Finch requires Elixir~> 1.15).Configuration
Notes
:http_client, so a bareUndefinedFunctionErrornaming the module you just typed is already self-diagnosing.Tests
Waffle.HTTPClient.Finch(mocked transport layer, redirects, body-size limiting, timeouts)parse_content_disposition/1helperstore_test.exstest that relied on hackney's internal header-parsing API