This pull request makes it easier to use custom APIRouters in FastAPI. It introduces a new router_class parameter in the FastAPI constructor, allowing users to specify their own custom router class. Additionally, it adds support for custom parameters in route decorators by extending the APIRoute class. Finally, it enables access to custom attributes or methods defined in the custom router class from within route handlers.
Summary
Added CustomRouter class that extends APIRouter and allows for custom logic before adding a route
Added support for initializing FastAPI with a custom router class using the router_class parameter
Added CustomAPIRoute class that extends APIRoute and allows for capturing additional parameters in route decorators
Added support for specifying a custom route class when adding routes to the application
Added support for accessing custom router attributes in route handlers
Updated the FastAPI constructor to include the router_class parameter
Updated the FastAPI constructor to use the specified router_class if provided
Updated the FastAPI constructor to fallback to the default APIRouter if no router_class is provided
Updated the get, put, post, delete, options, head, and patch decorators to include support for custom parameters
Fixes #2.
🎉 Latest improvements to Sweep:
New dashboard launched for real-time tracking of Sweep issues, covering all stages from search to coding.
Integration of OpenAI's latest Assistant API for more efficient and reliable code planning and editing, improving speed by 3x.
PR Feedback (click)
Description
This pull request makes it easier to use custom
APIRouter
s in FastAPI. It introduces a newrouter_class
parameter in theFastAPI
constructor, allowing users to specify their own custom router class. Additionally, it adds support for custom parameters in route decorators by extending theAPIRoute
class. Finally, it enables access to custom attributes or methods defined in the custom router class from within route handlers.Summary
CustomRouter
class that extendsAPIRouter
and allows for custom logic before adding a routerouter_class
parameterCustomAPIRoute
class that extendsAPIRoute
and allows for capturing additional parameters in route decoratorsFastAPI
constructor to include therouter_class
parameterFastAPI
constructor to use the specifiedrouter_class
if providedFastAPI
constructor to fallback to the defaultAPIRouter
if norouter_class
is providedget
,put
,post
,delete
,options
,head
, andpatch
decorators to include support for custom parametersFixes #2.
🎉 Latest improvements to Sweep:
💡 To get Sweep to edit this pull request, you can: