Repository: honeybadger-io/honeybadger-python (language: python)

Issue:
ASGI middleware/plugin.
Hello! I'm proposing the following PR that should close #78.

This PR adds ASGI applications support and a custom FastAPI route.
I added some tests and update the documentation.

What do you think @joshuap and @Kelvin4664?


Discussion / hints:
I forgot to mention—we will also need to add a [CHANGELOG.md](https://github.com/honeybadger-io/honeybadger-python/blob/master/CHANGELOG.md) entry before merging this (under the "Unreleased" heading).

Edit: I didn't mean to close the PR with this comment. 🤦 😁 
Hey @joshuap, thanks for your edits! I updated the changelog. :+1: 
Thanks!! @Kelvin4664 feel free to merge this if you think it's ready.
Unable to install async-asgi-testclient. @stefanondisponibile is there something we should do different?
Hey @Kelvin4664 , sorry but today I'm just on mobile and don't have a clear idea on why it is failing. I'll have a closer look and let you know my guess!

Fix patch:
diff --git a/README.md b/README.md
index e77f3cf..cc72e4f 100644
--- a/README.md
+++ b/README.md
@@ -200,13 +200,14 @@ A custom API Route is available at [`honeybadger.contrib.fastapi`](./honeybadger
 
 ```python
 from fastapi import FastAPI, APIRouter
-from honeybadger import honeybadger, contrib
+from honeybadger import honeybadger
+from honeybadger.contrib.fastapi import HoneybadgerRoute
 
 honeybadger.configure(api_key="<your-api-key>")
 app = FastAPI()
-app.router.route_class = contrib.HoneybadgerRoute
+app.router.route_class = HoneybadgerRoute
 
-router = APIRouter(route_class=contrib.HoneybadgerRoute)
+router = APIRouter(route_class=HoneybadgerRoute)
 
 ```
 
diff --git a/honeybadger/contrib/__init__.py b/honeybadger/contrib/__init__.py
index 6b005b0..d3a5b40 100644
--- a/honeybadger/contrib/__init__.py
+++ b/honeybadger/contrib/__init__.py
@@ -2,12 +2,10 @@
 from honeybadger.contrib.django import DjangoHoneybadgerMiddleware
 from honeybadger.contrib.aws_lambda import AWSLambdaPlugin
 from honeybadger.contrib.asgi import ASGIHoneybadger
-from honeybadger.contrib.fastapi import HoneybadgerRoute
 
 __all__ = [
     'FlaskHoneybadger',
     'DjangoHoneybadgerMiddleware',
     'AWSLambdaPlugin',
     'ASGIHoneybadger',
-    'HoneybadgerRoute'
 ]


Test patch:
diff --git a/honeybadger/tests/contrib/test_fastapi.py b/honeybadger/tests/contrib/test_fastapi.py
index 2508565..2046e7a 100644
--- a/honeybadger/tests/contrib/test_fastapi.py
+++ b/honeybadger/tests/contrib/test_fastapi.py
@@ -1,7 +1,7 @@
 import unittest
 import aiounittest
 import mock
-from honeybadger import contrib
+from honeybadger.contrib.fastapi import HoneybadgerRoute
 from fastapi import FastAPI
 from fastapi.testclient import TestClient
 
@@ -9,7 +9,7 @@
 class FastAPITestCase(unittest.TestCase):
     def setUp(self):
         app = FastAPI()
-        app.router.route_class = contrib.HoneybadgerRoute
+        app.router.route_class = HoneybadgerRoute
 
         @app.get("/ok")
         def ok_route():