Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

ranking-agent/asgiar

Repository files navigation

ARCHIVED: This repo was developed for tests in the Strider repo, but is no longer being used.

ASGIAR

Asynchronous Server Gateway Interface - Augmented Reality

ASGIAR mounts an ASGI application at a specified host and overlays it on top of the "real world", i.e. your typical network interfaces.

This augmented reality is available through httpcore and higher-level interfaces that use it, in particular httpx.

Example

import asyncio

from asgiar import ASGIAR
from fastapi import FastAPI
import httpx

APP = FastAPI()


async def test():
    """Handle /test."""
    return "OK"
APP.get("/test")(test)


async def main():
    """Run example."""
    with ASGIAR(APP, host="asgiar"):
        async with httpx.AsyncClient() as client:
            response = await client.get("http://asgiar/test")
        assert response.status_code == 200


if __name__ == "__main__":
    asyncio.run(main())

ASGIAR can be used as a context manager or a decorator.

ASGIAR behaves like you expect:

  • you may use ASGIAR in nested fashion to mock multiple hosts
  • if you make a request of an un-mocked host, you receive the genuine item
  • if you mock an existing host, the original becomes unreachable

Limitations

  • ASGIAR mocks an entire host - you may not pass through a subset of endpoints
  • your augmented reality can only be reached through httpcore (httpx) while making asynchronous requests, e.g. using httpx.AsyncClient

ASGI applications

Popular frameworks for producing ASGI applications include:

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages