Open JakNowy opened 3 months ago
I would love to be able to do something like this:
class MyModelRouter(EndpointCreator):
crud = MyModelCrud #self.crud cannot recognize custom methods when crud passed as param, unless __init__ overriden.
async def _create_endpoint(
self,
my_endpoint_query_params,
my_endpoint_deps,
):
# my_router_logic...
# ...
# ...
return await self.crud.my_crud_method(self.session)
router = MyModelRouter(
**other_params
)
resulting in default "get" endpoint and customized "create" one.
Do you think it's going to be implemented in the future?
We're getting a lot of experiences with different use cases in our project. I am going to provide a PR with a FastRouter which best meets our needs and observations for implementing customized routes.
Let's say you want to use
crud.get_joined
on your routerread_item
method. What you end up doing is something like:Implementing your own crud methods and calling them in overriden EndpointCreator methods should be common and simple approach, while currently it's quite verbose.