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
Setting the action name for chaining #288
Comments
You need the Chained dispatcher but it doesn't work the way you are implementing.
|
I see, but the issue is that I do not want to hardcode the namespace I'm now experimenting with a custom DispatcherType; I'll post a link as soon as I get something working, and then we can decide whether it's useful to Cutelyst (maybe its functionality can be incorporated into the Chained dispatcher), or not. |
hmm not sure if Perl Catalyst supports this, but perhaps the empty Chained instead of / could chain to /_name_space |
That would be perfect! Let me try and see if I manage to get it working that way, and if it all goes well I'll prepare a MR. |
Still not working. Issue: cutelyst#288
@dantti I would appreciate if you could have a look at the linked branch, because I'm kind of stuck :-) My controller is now: C_ATTR(user, :Chained("") :AutoArgs :CaptureArgs(1) :ActionClass(REST))
void user(Context *c, const QString &userId);
C_ATTR(updatePin, :Chained("user") :AutoArgs :ActionClass(REST))
void updatePin(Context *c); where the name of the controller (sub)class is |
Meanwhile, I've implemented a custom dispatcher in my own project, which can be found here: https://gitlab.com/studentario/studentario-server/-/commit/33947b494b372e0a7b21288c41021b0f46acf1b4 It reacts on two attributes:
For example: /* This serves the URL api/v1/users/<id>, which we declare as the "user" object */
C_ATTR(user, :Path :CaptureArgs(1) :Object("user") :ActionClass(REST))
void user(Context *c, const QString &userId);
/* This serves the URL api/v1/users/<id>/updatePin, which is a method the "user" object */
C_ATTR(updatePin, :OnObject("user") :ActionClass(REST))
void updatePin(Context *c);
C_ATTR(updatePassword, :OnObject("user") :ActionClass(REST))
void updatePassword(Context *c); |
I'm implementing a REST API (code is here, and I successfully got these endpoints exposed:
Now I want to add a new method, say on
/api/v1/users/{id}/changePassword
, but I haven't been able to figure out how to achieve that. I've been trying to use the:Chained
attribute, but I cannot make the action appear at the desired path. I don't fully understand what the value of the:Chained
attribute is; I'd like to be able to set an action ID on the base action, and then chain to that. For example,What is the way to achieve what I need? Does it involve playing with the Dispatcher classes, or is there an easier (and better) way?
The text was updated successfully, but these errors were encountered: