Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

APIController cannot register on router #163

Open
zhoujingryan opened this issue Jul 28, 2024 · 4 comments
Open

APIController cannot register on router #163

zhoujingryan opened this issue Jul 28, 2024 · 4 comments

Comments

@zhoujingryan
Copy link

APIController cannot register on router.
is this behavior intentional?
user can only register their apps api controllers on the root api instance.
but we often have a common app route on every app imo.
now:

PAYMENT_PREFIX = "/payment/"

@api_controller(PAYMENT_PREFIX)
Class SomePaymentController1:
    pass 


@api_controller(PAYMENT_PREFIX)
Class SomePaymentController2:
    pass 

prefer:

@api_controller()
Class SomePaymentController1:
    pass 


@api_controller()
Class SomePaymentController2:
    pass 

payment_router.add_controller("", SomePaymentController1)
payment_router.add_controller("", SomePaymentController2)

api.add_router("payment", payment_router)
@eadwinCode
Copy link
Owner

@zhoujingryan this is not supported at the moment

@eadwinCode
Copy link
Owner

Also checkout this out #162 if that helps

@MisaoDev
Copy link

It'd make a lot of sense to be able to register them on routers as well as the base api.

There is a Router class in ninja_extra after all, and you can use it like a regular ninja router, but you can only attach normal function based views to it and not the ninja_extra controllers.

The workaround for me is to use the desired full path in the controller definition. But of course if I change the routers I have to manually edit those paths as well.

@eadwinCode
Copy link
Owner

eadwinCode commented Nov 21, 2024

I will look into this. Sorry for late response @MisaoDev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants