-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #63 from ponytailer/inject-v2
Inject v2
- Loading branch information
Showing
25 changed files
with
513 additions
and
323 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
from .decorators import delete, get, patch, post, put | ||
from .group import Group | ||
from pydantic_client.decorators import delete, get, patch, post, put | ||
from pydantic_client.factory import PydanticClientFactory | ||
from pydantic_client.main import PydanticClient | ||
from pydantic_client.schema.client_config import ClientConfig | ||
|
||
__all__ = [ | ||
"PydanticClient", | ||
"PydanticClientFactory", | ||
"ClientConfig", | ||
"patch", | ||
"get", | ||
"post", | ||
"put", | ||
"delete", | ||
"Group", | ||
] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from .requests import RequestsClient | ||
from .aiohttp import AIOHttpClient | ||
from .httpx import HttpxClient |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,27 @@ | ||
from typing import Any, Type | ||
from typing import Any | ||
|
||
from requests import Session | ||
|
||
from pydantic_client.clients.abstract_client import AbstractClient | ||
from pydantic_client.proxy import ClientProxy, Proxy | ||
from pydantic_client.schema.http_request import HttpRequest | ||
|
||
|
||
class RequestsClient(AbstractClient): | ||
runner_class: Type[Proxy] = ClientProxy | ||
session = Session() | ||
|
||
def do_request(self, request: HttpRequest) -> Any: | ||
data, json = self.parse_request(request) | ||
headers = request.request_headers if request.request_headers \ | ||
else self.headers | ||
else self.config.headers | ||
|
||
try: | ||
return self.session.request( | ||
url=self.base_url + request.url, | ||
method=request.method, | ||
json=json, | ||
data=data, | ||
headers=headers | ||
headers=headers, | ||
timeout=self.config.timeout, | ||
).json() | ||
except BaseException as e: | ||
raise e |
Oops, something went wrong.