@@ -39,16 +39,19 @@ <h1 class="title">Module <code>supertokens_python.framework.fastapi.fastapi_midd
39
39
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
40
40
# License for the specific language governing permissions and limitations
41
41
# under the License.
42
+ from __future__ import annotations
42
43
43
- from typing import Union
44
+ from typing import TYPE_CHECKING, Union
44
45
45
46
from starlette.middleware.base import (BaseHTTPMiddleware,
46
47
RequestResponseEndpoint)
47
48
from supertokens_python.framework import BaseResponse
48
49
50
+ if TYPE_CHECKING:
51
+ from fastapi import FastAPI, Request
52
+
49
53
50
54
class Middleware(BaseHTTPMiddleware):
51
- from fastapi import FastAPI, Request
52
55
53
56
def __init__(self, app: FastAPI):
54
57
super().__init__(app)
@@ -98,7 +101,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
98
101
< dl >
99
102
< dt id ="supertokens_python.framework.fastapi.fastapi_middleware.Middleware "> < code class ="flex name class ">
100
103
< span > class < span class ="ident "> Middleware</ span > </ span >
101
- < span > (</ span > < span > app: fastapi.applications. FastAPI)</ span >
104
+ < span > (</ span > < span > app: FastAPI)</ span >
102
105
</ code > </ dt >
103
106
< dd >
104
107
< div class ="desc "> </ div >
@@ -107,7 +110,6 @@ <h2 class="section-title" id="header-classes">Classes</h2>
107
110
< span > Expand source code</ span >
108
111
</ summary >
109
112
< pre > < code class ="python "> class Middleware(BaseHTTPMiddleware):
110
- from fastapi import FastAPI, Request
111
113
112
114
def __init__(self, app: FastAPI):
113
115
super().__init__(app)
@@ -149,44 +151,10 @@ <h3>Ancestors</h3>
149
151
< ul class ="hlist ">
150
152
< li > starlette.middleware.base.BaseHTTPMiddleware</ li >
151
153
</ ul >
152
- < h3 > Class variables</ h3 >
153
- < dl >
154
- < dt id ="supertokens_python.framework.fastapi.fastapi_middleware.Middleware.FastAPI "> < code class ="name "> var < span class ="ident "> FastAPI</ span > </ code > </ dt >
155
- < dd >
156
- < div class ="desc "> < p > Creates an application instance.</ p >
157
- < p > < strong > Parameters:</ strong > </ p >
158
- < ul >
159
- < li > < strong > debug</ strong > - Boolean indicating if debug tracebacks should be returned on errors.</ li >
160
- < li > < strong > routes</ strong > - A list of routes to serve incoming HTTP and WebSocket requests.</ li >
161
- < li > < strong > middleware</ strong > - A list of middleware to run for every request. A starlette
162
- application will always automatically include two middleware classes.
163
- < code > ServerErrorMiddleware</ code > is added as the very outermost middleware, to handle
164
- any uncaught errors occurring anywhere in the entire stack.
165
- < code > ExceptionMiddleware</ code > is added as the very innermost middleware, to deal
166
- with handled exception cases occurring in the routing or endpoints.</ li >
167
- < li > < strong > exception_handlers</ strong > - A dictionary mapping either integer status codes,
168
- or exception class types onto callables which handle the exceptions.
169
- Exception handler callables should be of the form
170
- < code > handler(request, exc) -> response</ code > and may be be either standard functions, or
171
- async functions.</ li >
172
- < li > < strong > on_startup</ strong > - A list of callables to run on application startup.
173
- Startup handler callables do not take any arguments, and may be be either
174
- standard functions, or async functions.</ li >
175
- < li > < strong > on_shutdown</ strong > - A list of callables to run on application shutdown.
176
- Shutdown handler callables do not take any arguments, and may be be either
177
- standard functions, or async functions.</ li >
178
- </ ul > </ div >
179
- </ dd >
180
- < dt id ="supertokens_python.framework.fastapi.fastapi_middleware.Middleware.Request "> < code class ="name "> var < span class ="ident "> Request</ span > </ code > </ dt >
181
- < dd >
182
- < div class ="desc "> < p > A base class for incoming HTTP connections, that is used to provide
183
- any functionality that is common to both < code > Request</ code > and < code > WebSocket</ code > .</ p > </ div >
184
- </ dd >
185
- </ dl >
186
154
< h3 > Methods</ h3 >
187
155
< dl >
188
156
< dt id ="supertokens_python.framework.fastapi.fastapi_middleware.Middleware.dispatch "> < code class ="name flex ">
189
- < span > async def < span class ="ident "> dispatch</ span > </ span > (< span > self, request: starlette.requests. Request, call_next: Callable[[starlette.requests.Request], Awaitable[starlette.responses.Response]] )</ span >
157
+ < span > async def < span class ="ident "> dispatch</ span > </ span > (< span > self, request: Request, call_next: RequestResponseEndpoint )</ span >
190
158
</ code > </ dt >
191
159
< dd >
192
160
< div class ="desc "> </ div >
@@ -249,8 +217,6 @@ <h1>Index</h1>
249
217
< li >
250
218
< h4 > < code > < a title ="supertokens_python.framework.fastapi.fastapi_middleware.Middleware " href ="#supertokens_python.framework.fastapi.fastapi_middleware.Middleware "> Middleware</ a > </ code > </ h4 >
251
219
< ul class ="">
252
- < li > < code > < a title ="supertokens_python.framework.fastapi.fastapi_middleware.Middleware.FastAPI " href ="#supertokens_python.framework.fastapi.fastapi_middleware.Middleware.FastAPI "> FastAPI</ a > </ code > </ li >
253
- < li > < code > < a title ="supertokens_python.framework.fastapi.fastapi_middleware.Middleware.Request " href ="#supertokens_python.framework.fastapi.fastapi_middleware.Middleware.Request "> Request</ a > </ code > </ li >
254
220
< li > < code > < a title ="supertokens_python.framework.fastapi.fastapi_middleware.Middleware.dispatch " href ="#supertokens_python.framework.fastapi.fastapi_middleware.Middleware.dispatch "> dispatch</ a > </ code > </ li >
255
221
</ ul >
256
222
</ li >
0 commit comments