-
Notifications
You must be signed in to change notification settings - Fork 16
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 #287 from getappmap/fastapi_20240227
Add FastAPI support
- Loading branch information
Showing
56 changed files
with
1,029 additions
and
465 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
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
""" | ||
This file contains a FastAPI app that is mounted on /_appmap to expose the remote-recording endpoint | ||
in a user's app. | ||
It should only be imported if other code has already verified that FastAPI is available. | ||
""" | ||
|
||
from fastapi import FastAPI, Response | ||
|
||
from . import remote_recording | ||
|
||
app = FastAPI() | ||
|
||
|
||
def _rr_response(fn): | ||
body, rrstatus = fn() | ||
return Response(content=body, status_code=rrstatus, media_type="application/json") | ||
|
||
|
||
@app.get("/record") | ||
def status(): | ||
return _rr_response(remote_recording.status) | ||
|
||
|
||
@app.post("/record") | ||
def start(): | ||
return _rr_response(remote_recording.start) | ||
|
||
|
||
@app.delete("/record") | ||
def stop(): | ||
return _rr_response(remote_recording.stop) |
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,7 +1,6 @@ | ||
"""Shared metadata gathering""" | ||
|
||
import platform | ||
import re | ||
from functools import lru_cache | ||
|
||
from . import utils | ||
|
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import pytest | ||
|
||
# Make sure assertions in web_framework get rewritten (e.g. to show | ||
# diffs in generated appmaps) | ||
pytest.register_assert_rewrite("_appmap.test.web_framework") |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -x | ||
|
||
cd "$1"; shift | ||
|
||
set -a | ||
PYTHONUNBUFFERED=1 | ||
APPMAP_OUTPUT_DIR=/tmp | ||
PYTHONPATH=./init | ||
|
||
exec $@ |
Oops, something went wrong.