Skip to content
Myr

Add `status_code` endpoint

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Matus Ferech · committed by Matus Ferech · parent 2197015 · Browse files · 1 file+14 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+14 added−0 removed

  • tests:+14 added−0 removed

1 file+14 added−0 removed

modified:tests/conftest.py+14 added
7 unmodified lines
8async def app(scope, receive, send):9 assert scope["type"] == "http"10 if scope["path"] == "/slow_response":11 await slow_response(scope, receive, send)12 elif scope["path"].startswith("/status"):13 await status_code(scope, receive, send)14 else:15 await hello_world(scope, receive, send)1617
19 unmodified lines
37 )38 await send({"type": "http.response.body", "body": b"Hello, world!"})394041async def status_code(scope, receive, send):42 status_code = int(scope["path"].replace("/status/", ""))43 await send(44 {45 "type": "http.response.start",46 "status": status_code,47 "headers": [[b"content-type", b"text/plain"]],48 }49 )50 await send({"type": "http.response.body", "body": b"Hello, world!"})515253@pytest.fixture54async def server():55 config = Config(app=app, lifespan="off")56 server = Server(config=config)
8 unmodified lines