You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Today's approach for declarativex executors (both sync and async) creates new clients under the hood. This works fine as long as you are fine with basic httpx settings. Use Case section lists a number of additional features that can be unlocked if declarativex API can consume pre-configured httpx (and other) clients.
Use Case
Support for cookie retention between API calls
Support for self-signed certificates added at runtime (not via OS certificate chains)
Support for httpxevent hooks. This is a big one since declarativex Middleware consumes transformed responses, while httpx event hook can access raw request.
Advanced transport usage
Other httpx benefits
Async settings
Proposed Solution
Introduce new base_client (or client) BaseClient property (similar to base_url, timeout and others) / @http argument. When supplied respective Executor uses supplied client inside _execute method instead of creating new one during each _execute call.
The drawback is that follow_redirects, http2 and proxies settings will be ignored. Users must set those inside the client, but if they opt for custom client, they kinda know what they're doing.
Alternatives
Custom executor can be used instead, but this implies creation of custom @http annotation, which is kinda ugly.
Will try to file a PR once I get spare time to work on this.
The text was updated successfully, but these errors were encountered:
Description
Today's approach for declarativex executors (both sync and async) creates new clients under the hood. This works fine as long as you are fine with basic
httpx
settings.Use Case
section lists a number of additional features that can be unlocked ifdeclarativex
API can consume pre-configuredhttpx
(and other) clients.Use Case
httpx
event hooks. This is a big one sincedeclarativex
Middleware consumes transformed responses, whilehttpx
event hook can access raw request.httpx
benefitsProposed Solution
Introduce new
base_client
(orclient
) BaseClient property (similar tobase_url
,timeout
and others) /@http
argument. When supplied respectiveExecutor
uses supplied client inside_execute
method instead of creating new one during each_execute
call.The drawback is that
follow_redirects
,http2
andproxies
settings will be ignored. Users must set those inside theclient
, but if they opt for custom client, they kinda know what they're doing.Alternatives
Custom executor can be used instead, but this implies creation of custom
@http
annotation, which is kinda ugly.Will try to file a PR once I get spare time to work on this.
The text was updated successfully, but these errors were encountered: