1

ok i got this problem. i have this routes: (code bit change) File:/home/dotcloud/current/config/routes.js

exports.routes = function (map) {

    // Generic routes. Add all your routes below this line
    // feel free to remove generic routes
        //map.all(':controller/:action');
 //   map.all(':controller/:action/:id');


        var sitesControllers = [
                "RequestSiteLogin",
                "IsValidSiteLogin",
                "HoldSiteLogin",
                "RequestSiteProfile",
                "LogoutSite",
                "RevalidState"
        ];
        map.namespace('/subdomain/Users/:id/SitesCotnrol/', function (site) {
            site.resources('sites',{only: sitesControllers},function (action) {
                action.post("RequestSiteLogin","SitesCotnrol/RequestSiteLogin#:id");
                action.post("IsValidSiteLogin","SitesCotnrol/IsValidSiteLogin#:id");
                action.post("HoldSiteLogin","SitesCotnrol/HoldSiteLogin#:id");
                action.post("RequestSiteProfile","SitesCotnrol/RequestSiteProfile#:id");
                action.post("LogoutSite","SitesCotnrol/LogoutSite#:id");
                action.post("RevalidState","SitesCotnrol/RevalidSite#:id");
            });
        });

        var adminControllers = [
                "AddSite",
                "RemoveSite",
                "HoldAllSites",
                "LogoutApplication",
                "UpdateApplicationSettings",
                "Echo"
        ];
        map.namespace('/subdomain/Applciation/Control',function (admin) {
        admin.resources('admin',{only: adminControllers},function (action) {
        action.post("AddSite","/subdomain/Application/Control/AddSite");
        action.post("RemoveSite","/subdomain/Application/Control/RemoveSite#:id");
        action.get("Echo","#echo");
        action.get("HoldAllSites","/subdomain/Application/Control/HoleAll");
        action.get("LogoutApplication","/subdomain/Application/Control/LogoutApplication");
        action.get("UpdateApplicationSettings","/subdomain/Application/Control/UpdateApplicationSettings");
    });
});
};

now the url i try start is this: http://application.pmpdevelopmentfront.tk/control#echo the error within the page the param ControlDomain is same as subdomain see https://github.com/WilsonPage/express-subdomain-handler please dont sure what do here.

Update on the routes thu cli:

dotcloud@frontend-default-www-0:~/current$ ./node_modules/railway/bin/railway  routes
   info  - socket.io started
        _subdomain_User_SitesCotnrol_site_RequestSiteLogin POST   //subdomain/Users/:id/SitesCotnrol/sites/:site_id/RequestSiteLogin        /subdomain/Users/:id/SitesCotnrol/SitesCotnrol/RequestSiteLogin#:id
        _subdomain_User_SitesCotnrol_site_IsValidSiteLogin POST   //subdomain/Users/:id/SitesCotnrol/sites/:site_id/IsValidSiteLogin        /subdomain/Users/:id/SitesCotnrol/SitesCotnrol/IsValidSiteLogin#:id
           _subdomain_User_SitesCotnrol_site_HoldSiteLogin POST   //subdomain/Users/:id/SitesCotnrol/sites/:site_id/HoldSiteLogin           /subdomain/Users/:id/SitesCotnrol/SitesCotnrol/HoldSiteLogin#:id
      _subdomain_User_SitesCotnrol_site_RequestSiteProfile POST   //subdomain/Users/:id/SitesCotnrol/sites/:site_id/RequestSiteProfile      /subdomain/Users/:id/SitesCotnrol/SitesCotnrol/RequestSiteProfile#:id
              _subdomain_User_SitesCotnrol_site_LogoutSite POST   //subdomain/Users/:id/SitesCotnrol/sites/:site_id/LogoutSite              /subdomain/Users/:id/SitesCotnrol/SitesCotnrol/LogoutSite#:id
            _subdomain_User_SitesCotnrol_site_RevalidState POST   //subdomain/Users/:id/SitesCotnrol/sites/:site_id/RevalidState            /subdomain/Users/:id/SitesCotnrol/SitesCotnrol/RevalidSite#:id
                   _subdomain_Applciation_Control__AddSite POST   //subdomain/Applciation/Control/admin/:admin_id/AddSite                   /subdomain/Applciation/Control//subdomain/Application/Control/AddSite#undefined
                _subdomain_Applciation_Control__RemoveSite POST   //subdomain/Applciation/Control/admin/:admin_id/RemoveSite                /subdomain/Applciation/Control//subdomain/Application/Control/RemoveSite#:id
                      _subdomain_Applciation_Control__Echo GET    //subdomain/Applciation/Control/admin/:admin_id/Echo                      /subdomain/Applciation/Control/#echo
              _subdomain_Applciation_Control__HoldAllSites GET    //subdomain/Applciation/Control/admin/:admin_id/HoldAllSites              /subdomain/Applciation/Control//subdomain/Application/Control/HoleAll#undefined
         _subdomain_Applciation_Control__LogoutApplication GET    //subdomain/Applciation/Control/admin/:admin_id/LogoutApplication         /subdomain/Applciation/Control//subdomain/Application/Control/LogoutApplication#undefined
 _subdomain_Applciation_Control__UpdateApplicationSettings GET    //subdomain/Applciation/Control/admin/:admin_id/UpdateApplicationSettings /subdomain/Applciation/Control//subdomain/Application/Control/UpdateApplicationSettings#undefined
Sivan Wolberg
  • 348
  • 2
  • 6
  • 18
  • Just from looking at the code, it appears that the line with /ControlDomain/Application/Control#Echo is different from the other lines, which seem to name a controller defined in adminControllers. Could it be that you're missing a controller name as first parameter? – Timothy Meade Apr 05 '12 at 08:27
  • ok action.get("/ControlDomain/Application/Control#Echo","Echo"); or this action.get("Echo","/ControlDomain/Application/Control#Echo"); act the same for still give me this issue . also what u mean by that if need can give u the controller code i have no idea what to fix here – Sivan Wolberg Apr 05 '12 at 08:51

1 Answers1

2

First of all, remove generic routes:

// Generic routes. Add all your routes below this line
// feel free to remove generic routes
map.all(':controller/:action');
map.all(':controller/:action/:id');

Second thing you may miss: namespace. Try to debug your routes using CLI: railway routes

And third: need to check your esh initialization (correct prefixes, hooking up admin namespace prefix correctly).

BTW: subdomains looks like missing feature in current railway-routes implementation. Why not just add subdomain handling to this module and avoid additional code and dependencies.

Anatoliy
  • 29,485
  • 5
  • 46
  • 45
  • what u mean by "subdomains looks like missing feature in current railway-routes implementation. Why not just add subdomain handling to this module and avoid additional code and dependencies." like thu control panel?? – Sivan Wolberg Apr 05 '12 at 10:25
  • 1
    I mean I know way to implement routes using subdomains inside railway-routes and railway. Will release this feature to master soon. It allow you to configure your routes like that: `map.get('/path', 'controller#action', {subdomain: 'admin'});` – Anatoliy Apr 05 '12 at 10:58
  • Could you explain what do you want to get as a result? – Anatoliy Apr 05 '12 at 11:22
  • simple i have project that need be secure and alot. there 2 side one for apliication control and order is user control that the user need have 2 level subdomain exmple users.444.mydomain.com/login and exmple for allication apllication.mydomain.com/control/echo – Sivan Wolberg Apr 05 '12 at 11:28
  • 2
    Okay, I've just pushed subdomain support (beta, not tested yet) to railwayjs master branch. Working fine for me. Use syntax as described before. req.subdomain has current subdomain. Wildcards also supported: {subdomain: 'users.*'}. Be default top domain size configured as 2 (example.com), so 'user.123.example.com' subdomain will 'user.123'. If you want to change it user: `railway.ControllerBridge.config.subdomain.tld = 1;` and you get subdomain = 'user.123.example' – Anatoliy Apr 05 '12 at 12:13
  • can u send a doc about at dont mind help u test this as long its do hehe wont mind help as well in the project just need doc about what u told here but kool hehe:) – Sivan Wolberg Apr 05 '12 at 12:22
  • have question how do i get the params from that subdomain let take the exmple of users.444.mydomain.com/login the 444 its param i must ??? – Sivan Wolberg Apr 05 '12 at 12:25
  • Check `req.subdomain` inside controller action. Docs will be updated as soon as we'll get stable api for this crap. I want to support some more configurable constraints, using regexes or so. For now feel free to ask questions here. – Anatoliy Apr 05 '12 at 13:00
  • can u show exmple of req.subdomain like say how i get from my exmple users.444.mydomain.com/login like how i can get 444 like i do req.subdomain.users.444 or what?? – Sivan Wolberg Apr 05 '12 at 13:26
  • When you GET http://users.444.mydomain.com/login, and your route looks like: `app.get('/login', 'session#new', {subdomain: "users.*"});` you will get following result in controller: req.subdomain // 'users.444', so, if you want to get '444' your code is `req.subdomain.split('.').pop()`. – Anatoliy Apr 05 '12 at 14:18
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/9735/discussion-between-anatoliy-and-sivan-wolberg) – Anatoliy Apr 05 '12 at 14:19