Placeholders in base URL #2679
-
|
Is it possible to provide a base URL to Client with placeholders (similar to f-strings/format)? Either named or positional? Something like: |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
|
I thought it'd be interesting to see what ChatGPT says... |
Beta Was this translation helpful? Give feedback.
-
|
Yeah, that's similar to what I did, but I have a function. from httpx import Client
from syncer import config
class HTTPClient:
def __init__(self):
self._client = None
self._default_headers = {"Content-Type": "application/json"}
self._default_params = {"api-version": "7.0"}
def client(self):
if self._client is None:
self._client = Client(
auth=("", config.get("pat")),
headers=self._default_headers,
params=self._default_params,
)
return self._client
def url(org_id, project_id, endpoint):
return f"https://dev.azure.com/{org_id}/{project_id}/_apis/wit/workitems/{endpoint}"and a call might look like: response = self._http_client.delete(
url(self.org, self.project_id, self.id),
) |
Beta Was this translation helpful? Give feedback.
-
|
Would you review a PR providing this feature @tomchristie ? |
Beta Was this translation helpful? Give feedback.



Yeah, that's similar to what I did, but I have a function.