Skip to content

feat: 更多的 HTTP / ASGI 组件#34

Open
RF-Tar-Railt wants to merge 10 commits into
masterfrom
feat/network
Open

feat: 更多的 HTTP / ASGI 组件#34
RF-Tar-Railt wants to merge 10 commits into
masterfrom
feat/network

Conversation

@RF-Tar-Railt

Copy link
Copy Markdown
Member

No description provided.

@BlueGlassBlock

Copy link
Copy Markdown
Member

@copilot Summarize pull request content

Copilot AI commented Mar 25, 2026

Copy link
Copy Markdown

@copilot Summarize pull request content

This PR adds expanded HTTP client and ASGI server support to the Amnesia framework across 8 commits (+2374/-475 lines, 23 files changed):

HTTP Client Layer (builtins/http/)

  • Generic HTTP types (httptypes.py, 456 lines): Library-agnostic Request/Response models with headers, cookies, multipart, JSON, streaming support, and type aliases (HeadersType, QueryType, FormDataType, etc.).
  • Base class (base.py): Abstract HttpClientService extending launart.Service with a unified request() interface.
  • 4 client implementations, each wrapping a different library into the common interface:
    • aiohttpAiohttpClientService
    • httpxHttpxClientService
    • niquestsNiquestsClientService
    • pyreqwestPyReqwestClientService
  • Auto-discovery (__init__.py): Lazy imports with helpful error messages, plus a top-level request() helper that auto-selects whichever HTTP client is installed and registered with Launart.

ASGI Server Layer (builtins/asgi/)

  • Granian support (granian.py, 120 lines): New GranianASGIService with GranianOptions dataclass for the Granian ASGI server.
  • Refactored existing Uvicorn and Hypercorn services (simplified by ~130 lines combined).
  • Lazy __init__.py: Unified import pattern with graceful ImportError handling for all three ASGI servers.

Other

  • New optional dependencies in pyproject.toml (niquests, pyreqwest_impersonate, granian).
  • Example scripts (exam_aio.py, exam_granian.py, exam_uvicorn.py) and pre-commit config update.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants