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

multiple route_param example #81

Closed
lmasarati opened this issue Sep 11, 2019 · 5 comments
Closed

multiple route_param example #81

lmasarati opened this issue Sep 11, 2019 · 5 comments

Comments

@lmasarati
Copy link

Hello, I'm wondering if an API call like this could be done and how...
GET http://example/api/:id1/:id2/:id3

The goal is to receive the three route_param id1, id2 and id3 in the get sub {} and then process them as needed...
Thanks.

@khrt
Copy link
Owner

khrt commented Sep 11, 2019

I think it's related to #77

@lmasarati
Copy link
Author

yes, I suspected...
So the sample code could be something like this?

desc "multiple route_param";
resource "api" => sub {
	params(
		requires('id1', type => Str, desc => "ID1")
		requires('id2', type => Str, desc => "ID2"),
		requires('id3', type => Str, desc => "ID3")
	);
	route_param 'id1' => sub {
		route_param 'id2' => sub {
			route_param 'id3' => sub {
				get sub {
					my $params = shift;
					return $params;
				};
			};
		};
	};
};

@khrt
Copy link
Owner

khrt commented Sep 11, 2019

Yes, exactly. Once I fix it. Unfortunately I had no time yet to work on it, but it's my priority to fix.

@khrt
Copy link
Owner

khrt commented Sep 14, 2019

Here is a better example:

    params requires => { name => 'id', type => Int };
    route_param id => sub {
        get sub { ... };

        params requires => { name => 'sub_id', type => Int };
        route_param sub_id => sub {
            ...
        };
    };

Also extended documentation: https://github.com/khrt/Raisin/blob/93e806c/lib/Raisin.pm#L458

@khrt khrt closed this as completed Sep 14, 2019
@khrt
Copy link
Owner

khrt commented Sep 14, 2019

Fix for #77 was merged and realised to CPAN, see Raisin 0.87

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

2 participants