valid (i thought) route gives me 404

36 views
Skip to first unread message

Richard Sugg

unread,
Apr 11, 2014, 11:50:18 AM4/11/14
to mojol...@googlegroups.com
As far as I can tell, I have a valid route for check_password_user, but when I GET it, I get 404 back. Why doesn't this route match? When I run the routes command, I get back

/api/2/domain/:domainid/project/:projid/user  *        api2domaindomainidprojectprojiduser
  +/                                          POST     "create_user"
  +/                                          GET      "list_user"
  +/:userid                                   *        userid
    +/                                        GET      "show_user"
    +/                                        DELETE   "delete_user"
    +/                                        PUT      "update_user"
    +/password                                *        password
      +/:password                             GET      "check_password_user"

which I think means the url 

/api/2/domain/:domainid/project/:projid/user/:userid/password/:password

would be a match for 

/api/2/domain/MyDomain/project/MyProject/user/MyUser/password/Secret

where domainid=MyDomain, project=MyProject, userid=MyUser, password=Secret

but that URL will return 404 everytime.

Richard Sugg

unread,
Apr 11, 2014, 11:52:38 AM4/11/14
to mojol...@googlegroups.com
I also put

my $url = $self->url_for("check_password_user", domainid => 'MyDomain', projid => 'Z', userid => 'MyUser', password => 'secret');

right after the route was defined. The URL it produced gave 404:

/api/2/domain/MyDomain/project/Z/user/MyUser/password/secret

sri

unread,
Apr 11, 2014, 12:01:48 PM4/11/14
to mojol...@googlegroups.com
I would recommend posting the output of "routes -v" rather than that of the 404 page.


It shows a lot more details.

--
sebastian

Richard Sugg

unread,
Apr 14, 2014, 11:10:14 AM4/14/14
to mojol...@googlegroups.com
Here's routes with -v as well as the route manually defined at the bottom (manual_check_password_user). The route at the bottom matches, and I thought it should be the same as route "check_password_user":

/api/2/domain/:domainid/project/:projid/user                             ....  *        api2domaindomainidprojectprojiduser  ^/api/2/domain/([^\/\.]+)/project/([^\/\.]+)/user
  +/                                                                     ....  POST     "create_user"                        ^(?:\.([^/]+)$)?
  +/                                                                     ....  GET      "list_user"                          ^(?:\.([^/]+)$)?
  +/:userid                                                              ....  *        userid                               ^/([^\/\.]+)
    +/                                                                   ....  GET      "show_user"                          ^(?:\.([^/]+)$)?
    +/                                                                   ....  DELETE   "delete_user"                        ^(?:\.([^/]+)$)?
    +/                                                                   ....  PUT      "update_user"                        ^(?:\.([^/]+)$)?
    +/password                                                           ....  *        password                             ^/password
      +/:password                                                        ....  GET      "check_password_user"                ^/([^\/\.]+)
        +/validate/:pw_b64                                               ....  GET      "validate_password_user"             ^/validate/([^\/\.]+)
          +/change/:current_b64/:new_b64                                 ....  PUT      "change_password_user"               ^/change/([^\/\.]+)/([^\/\.]+)
            +/reset                                                      ....  PUT      "reset_password_user"                ^/reset(?:\.([^/]+)$)?
/api/2/domain/:domainid/project/:projid/user/:userid/password/:password  ....  GET      "manual_check_password_user"         ^/api/2/domain/([^\/\.]+)/project/([^\/\.]+)/user/([^\/\.]+)/password/([^\/\.]+)(?:\.([^/]+)$)?

Richard Sugg

unread,
Apr 14, 2014, 1:24:58 PM4/14/14
to mojol...@googlegroups.com
not entirely sure why the route didn't match as expected, but I changed the route a bit and now it works
Reply all
Reply to author
Forward
0 new messages