Thread: [Cppcms-users] URL maps
Brought to you by:
artyom-beilis
From: Renato F. <re....@ay...> - 2011-03-25 13:16:14
|
Hi, I am try understand how group and map url. For sample I have 2 classes: class Home : public cppcms::application class Test : public cppcms::application And a class that I can group apps: class App : public cppcms::application { public: Home _home; Test _test; App(cppcms::service &s) : cppcms::application(s) , _home(s) , _test(s) { add(_test, "/test", 1); add(_home, "/home", 2); } }; int main(int argc,char ** argv) { try { cppcms::service srv(argc, argv); srv.applications_pool().mount(cppcms::applications_factory<App>()); srv.run(); } catch(std::exception const &e) { std::cerr<<e.what()<<std::endl; } } But when I'd tried access like: http://localhost:8080/test or http://localhost:8080/home Don't work, What is wrong? My config file: { "service" : { "api" : "http", "port" : 8080, "worker_threads" : 20, }, "http" : { "script" : "/" }, "file_server" : { "enable" : true }, "session" : { "expire" : "renew", "timeout" : 604800, "location" : "client", "client" : { "encryptor" : "hmac", "key" : "232074faa0fd37de20858bf8cd0a7d04" } }, } Thaks |
From: Pavel K. <un...@fu...> - 2011-03-25 13:50:47
|
hi, before Artyom gives you more sopisticated answer, look at attach() method (enables generating url - look at blog example). /// Register an application \a app as child and mount it into: /// /// - url_dispatcher calling dispatcher().mount(regex,*app,part); /// - url_mapper calling mapper().mount(name,url,*app); /// /// Ownership of app is transfered to parent. /// void attach(application *app,std::string const &name,std::string const &url,std::string const ®ex,int part); example from my application> attach( new apps::photo( s ), "photo", "/photo{1}", "/photo((/.*)?)", 1 ); attach( new apps::user::app_user( s ), "user", "/user{1}", "/user((/.*)?)", 1 ); pavel. On Friday 25 March 2011, Renato Forti wrote: > Hi, > I am try understand how group and map url. > For sample I have 2 classes: > { > > add(_test, "/test", 1); > > add(_home, "/home", 2); > > } > }; |
From: Pavel K. <un...@fu...> - 2011-03-25 14:20:22
|
and to attach "ending app" without parameters or more possible "views"> welcome::welcome( cppcms::service &srv ) : master_full( srv ) { dispatcher().assign( "/?", &welcome::display, this ); mapper().assign( "" ); } void welcome::display() { } |
From: Renato F. <re....@ay...> - 2011-03-25 14:30:35
|
Hi Thanks again, Well, my cppcms::application have 2 attachs: void attach(application *app); void attach(application *app,std::string regex,int part); then Id try: class App : public cppcms::application { public: App(cppcms::service &s) : cppcms::application(s) { attach( new Test( s ), "test", "/test{1}", "/test((/.*)?)", 1 ); attach( new Portal( s ), "portal", "/portal{1}", "/portal((/.*)?)", 1 ); } }; But I receive this error of compiler: 1>e:\project.vgsws\main.cpp(362) : error C2661: 'cppcms::application::attach' : no overloaded function takes 5 arguments 1>e:\project.vgsws\main.cpp(367) : error C2661: 'cppcms::application::attach' : no overloaded function takes 5 arguments I am using: cppcms-0.99.6 I am confusing in how use a class to represent an Page/URL. Thanks for help. De: Pavel Kropitz [mailto:un...@fu...] Enviada em: sexta-feira, 25 de março de 2011 10:51 Para: cpp...@li... Assunto: Re: [Cppcms-users] URL maps hi, before Artyom gives you more sopisticated answer, look at attach() method (enables generating url - look at blog example). /// Register an application \a app as child and mount it into: /// /// - url_dispatcher calling dispatcher().mount(regex,*app,part); /// - url_mapper calling mapper().mount(name,url,*app); /// /// Ownership of app is transfered to parent. /// void attach(application *app,std::string const &name,std::string const &url,std::string const ®ex,int part); example from my application> attach( new apps::photo( s ), "photo", "/photo{1}", "/photo((/.*)?)", 1 ); attach( new apps::user::app_user( s ), "user", "/user{1}", "/user((/.*)?)", 1 ); pavel. On Friday 25 March 2011, Renato Forti wrote: > Hi, > I am try understand how group and map url. > For sample I have 2 classes: > { > > add(_test, "/test", 1); > > add(_home, "/home", 2); > > } > }; |
From: Pavel K. <un...@fu...> - 2011-03-25 14:43:24
|
try more recent version ;) commit from Wed Feb 2 19:15:37 2011 UTC http://cppcms.svn.sourceforge.net/viewvc/cppcms/framework/trunk/cppcms/application.h?r1=1671&r2=1672 On Friday 25 March 2011, Renato Forti wrote: > Hi Thanks again, > Well, my cppcms::application have 2 attachs: > > > > void attach(application *app); > > void attach(application *app,std::string regex,int part); |
From: Cristian O. <one...@gm...> - 2011-03-25 14:52:42
|
I think that your problem is that "/test" and "/home" are missing from the scripts section of the configuration file. On Fri, Mar 25, 2011 at 3:15 PM, Renato Forti <re....@ay...> wrote: > Hi, > > > > I am try understand how group and map url. > > > > For sample I have 2 classes: > > > > class Home : public cppcms::application > > class Test : public cppcms::application > > > > And a class that I can group apps: > > > > class App : public cppcms::application > > { > > public: > > > > Home _home; > > Test _test; > > > > App(cppcms::service &s) > > : cppcms::application(s) > > , _home(s) > > , _test(s) > > { > > add(_test, "/test", 1); > > add(_home, "/home", 2); > > } > > }; > > > > > > > > int main(int argc,char ** argv) > > { > > try > > { > > cppcms::service srv(argc, argv); > > srv.applications_pool().mount(cppcms::applications_factory<App>()); > > srv.run(); > > } > > catch(std::exception const &e) > > { > > std::cerr<<e.what()<<std::endl; > > } > > } > > > > But when I’d tried access like: > > > > http://localhost:8080/test > > or > > http://localhost:8080/home > > > > Don’t work, What is wrong? > > > > My config file: > > > > { > > > > "service" : { > > "api" : "http", > > "port" : 8080, > > "worker_threads" : 20, > > > > }, > > "http" : { > > "script" : "/" > > }, > > "file_server" : { > > "enable" : true > > }, > > "session" : { > > "expire" : "renew", > > "timeout" : 604800, > > "location" : "client", > > "client" : { > > "encryptor" : "hmac", > > "key" : > "232074faa0fd37de20858bf8cd0a7d04" > > } > > }, > > } > > > > Thaks > > ------------------------------------------------------------------------------ > Enable your software for Intel(R) Active Management Technology to meet the > growing manageability and security demands of your customers. Businesses > are taking advantage of Intel(R) vPro (TM) technology - will your software > be a part of the solution? Download the Intel(R) Manageability Checker > today! http://p.sf.net/sfu/intel-dev2devmar > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > > |
From: Renato F. <re....@ay...> - 2011-03-25 14:58:20
|
Like this: "http" : { "script_names" : [ "/test", "/ home " ] }, :o(, I did try, but don't work... Any tip? Thanks, thanks, thanks... -----Mensagem original----- De: Cristian Oneț [mailto:one...@gm...] Enviada em: sexta-feira, 25 de março de 2011 11:53 Para: cpp...@li... Assunto: Re: [Cppcms-users] URL maps I think that your problem is that "/test" and "/home" are missing from the scripts section of the configuration file. On Fri, Mar 25, 2011 at 3:15 PM, Renato Forti <re....@ay...> wrote: > Hi, > > > > I am try understand how group and map url. > > > > For sample I have 2 classes: > > > > class Home : public cppcms::application > > class Test : public cppcms::application > > > > And a class that I can group apps: > > > > class App : public cppcms::application > > { > > public: > > > > Home _home; > > Test _test; > > > > App(cppcms::service &s) > > : cppcms::application(s) > > , _home(s) > > , _test(s) > > { > > add(_test, "/test", 1); > > add(_home, "/home", 2); > > } > > }; > > > > > > > > int main(int argc,char ** argv) > > { > > try > > { > > cppcms::service srv(argc, argv); > > srv.applications_pool().mount(cppcms::applications_factory<App>()); > > srv.run(); > > } > > catch(std::exception const &e) > > { > > std::cerr<<e.what()<<std::endl; > > } > > } > > > > But when I’d tried access like: > > > > http://localhost:8080/test > > or > > http://localhost:8080/home > > > > Don’t work, What is wrong? > > > > My config file: > > > > { > > > > "service" : { > > "api" : "http", > > "port" : 8080, > > "worker_threads" : 20, > > > > }, > > "http" : { > > "script" : "/" > > }, > > "file_server" : { > > "enable" : true > > }, > > "session" : { > > "expire" : "renew", > > "timeout" : 604800, > > "location" : "client", > > "client" : { > > "encryptor" : "hmac", > > "key" : > "232074faa0fd37de20858bf8cd0a7d04" > > } > > }, > > } > > > > Thaks > > ---------------------------------------------------------------------- > -------- Enable your software for Intel(R) Active Management > Technology to meet the growing manageability and security demands of > your customers. Businesses are taking advantage of Intel(R) vPro (TM) > technology - will your software be a part of the solution? Download > the Intel(R) Manageability Checker today! > http://p.sf.net/sfu/intel-dev2devmar > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > > ------------------------------------------------------------------------------ Enable your software for Intel(R) Active Management Technology to meet the growing manageability and security demands of your customers. Businesses are taking advantage of Intel(R) vPro (TM) technology - will your software be a part of the solution? Download the Intel(R) Manageability Checker today! http://p.sf.net/sfu/intel-dev2devmar _______________________________________________ Cppcms-users mailing list Cpp...@li... https://lists.sourceforge.net/lists/listinfo/cppcms-users |
From: Cristian O. <one...@gm...> - 2011-03-25 15:28:58
|
It does not work because you application is mounted at '/' and your sub-applications at '/test' and '/home' and that's relative to your parent application's mountpoint. So after '/' is matched for your main application you will only have 'test' (not '/test') or 'home' (not '/home') left from the url to match and it will not match. On Fri, Mar 25, 2011 at 4:57 PM, Renato Forti <re....@ay...> wrote: > Like this: > > "http" : { > "script_names" : [ "/test", "/ home " ] > }, > > :o(, I did try, but don't work... > > Any tip? > > Thanks, thanks, thanks... > > -----Mensagem original----- > De: Cristian Oneț [mailto:one...@gm...] > Enviada em: sexta-feira, 25 de março de 2011 11:53 > Para: cpp...@li... > Assunto: Re: [Cppcms-users] URL maps > > I think that your problem is that "/test" and "/home" are missing from the scripts section of the configuration file. > > On Fri, Mar 25, 2011 at 3:15 PM, Renato Forti <re....@ay...> wrote: >> Hi, >> >> >> >> I am try understand how group and map url. >> >> >> >> For sample I have 2 classes: >> >> >> >> class Home : public cppcms::application >> >> class Test : public cppcms::application >> >> >> >> And a class that I can group apps: >> >> >> >> class App : public cppcms::application >> >> { >> >> public: >> >> >> >> Home _home; >> >> Test _test; >> >> >> >> App(cppcms::service &s) >> >> : cppcms::application(s) >> >> , _home(s) >> >> , _test(s) >> >> { >> >> add(_test, "/test", 1); >> >> add(_home, "/home", 2); >> >> } >> >> }; >> >> >> >> >> >> >> >> int main(int argc,char ** argv) >> >> { >> >> try >> >> { >> >> cppcms::service srv(argc, argv); >> >> srv.applications_pool().mount(cppcms::applications_factory<App>()); >> >> srv.run(); >> >> } >> >> catch(std::exception const &e) >> >> { >> >> std::cerr<<e.what()<<std::endl; >> >> } >> >> } >> >> >> >> But when I’d tried access like: >> >> >> >> http://localhost:8080/test >> >> or >> >> http://localhost:8080/home >> >> >> >> Don’t work, What is wrong? >> >> >> >> My config file: >> >> >> >> { >> >> >> >> "service" : { >> >> "api" : "http", >> >> "port" : 8080, >> >> "worker_threads" : 20, >> >> >> >> }, >> >> "http" : { >> >> "script" : "/" >> >> }, >> >> "file_server" : { >> >> "enable" : true >> >> }, >> >> "session" : { >> >> "expire" : "renew", >> >> "timeout" : 604800, >> >> "location" : "client", >> >> "client" : { >> >> "encryptor" : "hmac", >> >> "key" : >> "232074faa0fd37de20858bf8cd0a7d04" >> >> } >> >> }, >> >> } >> >> >> >> Thaks >> >> ---------------------------------------------------------------------- >> -------- Enable your software for Intel(R) Active Management >> Technology to meet the growing manageability and security demands of >> your customers. Businesses are taking advantage of Intel(R) vPro (TM) >> technology - will your software be a part of the solution? Download >> the Intel(R) Manageability Checker today! >> http://p.sf.net/sfu/intel-dev2devmar >> _______________________________________________ >> Cppcms-users mailing list >> Cpp...@li... >> https://lists.sourceforge.net/lists/listinfo/cppcms-users >> >> > ------------------------------------------------------------------------------ > Enable your software for Intel(R) Active Management Technology to meet the growing manageability and security demands of your customers. Businesses are taking advantage of Intel(R) vPro (TM) technology - will your software be a part of the solution? Download the Intel(R) Manageability Checker today! http://p.sf.net/sfu/intel-dev2devmar > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > ------------------------------------------------------------------------------ > Enable your software for Intel(R) Active Management Technology to meet the > growing manageability and security demands of your customers. Businesses > are taking advantage of Intel(R) vPro (TM) technology - will your software > be a part of the solution? Download the Intel(R) Manageability Checker > today! http://p.sf.net/sfu/intel-dev2devmar > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > |
From: Renato F. <re....@ay...> - 2011-03-25 15:57:21
|
Thanks for help, How config file should be to work? This is what I have: { "vws" : { "media" : "/media", "root" : "/vws", "host" : "localhost:8080", "connection-string-dir" : "E:\\project.vgsws\\resources\\connection-strings" }, "service" : { "api" : "http", "port" : 8080, "worker_threads" : 20, }, "http" : { "script" : "/", "script_names" : [ "/test", "/portal" ] }, "file_server" : { "enable" : true }, "session" : { "expire" : "renew", "timeout" : 604800, "location" : "client", "client" : { "encryptor" : "hmac", "key" : "232074faa0fd37de20858bf8cd0a7d04" } }, } And in class: class App : public cppcms::application { public: Test _test; Portal _portal; App(cppcms::service &s) : cppcms::application(s) , _test(s) , _portal(s) { add(_test, "/test", 1); add(_portal, "/portal", 1); } }; Thank you very much, for help. -----Mensagem original----- De: Cristian Oneț [mailto:one...@gm...] Enviada em: sexta-feira, 25 de março de 2011 12:29 Para: cpp...@li... Assunto: Re: [Cppcms-users] RES: URL maps It does not work because you application is mounted at '/' and your sub-applications at '/test' and '/home' and that's relative to your parent application's mountpoint. So after '/' is matched for your main application you will only have 'test' (not '/test') or 'home' (not '/home') left from the url to match and it will not match. On Fri, Mar 25, 2011 at 4:57 PM, Renato Forti <re....@ay...> wrote: > Like this: > > "http" : { > "script_names" : [ "/test", "/ home " ] > }, > > :o(, I did try, but don't work... > > Any tip? > > Thanks, thanks, thanks... > > -----Mensagem original----- > De: Cristian Oneț [mailto:one...@gm...] Enviada em: > sexta-feira, 25 de março de 2011 11:53 > Para: cpp...@li... > Assunto: Re: [Cppcms-users] URL maps > > I think that your problem is that "/test" and "/home" are missing from the scripts section of the configuration file. > > On Fri, Mar 25, 2011 at 3:15 PM, Renato Forti <re....@ay...> wrote: >> Hi, >> >> >> >> I am try understand how group and map url. >> >> >> >> For sample I have 2 classes: >> >> >> >> class Home : public cppcms::application >> >> class Test : public cppcms::application >> >> >> >> And a class that I can group apps: >> >> >> >> class App : public cppcms::application >> >> { >> >> public: >> >> >> >> Home _home; >> >> Test _test; >> >> >> >> App(cppcms::service &s) >> >> : cppcms::application(s) >> >> , _home(s) >> >> , _test(s) >> >> { >> >> add(_test, "/test", 1); >> >> add(_home, "/home", 2); >> >> } >> >> }; >> >> >> >> >> >> >> >> int main(int argc,char ** argv) >> >> { >> >> try >> >> { >> >> cppcms::service srv(argc, argv); >> >> srv.applications_pool().mount(cppcms::applications_factory<App>()); >> >> srv.run(); >> >> } >> >> catch(std::exception const &e) >> >> { >> >> std::cerr<<e.what()<<std::endl; >> >> } >> >> } >> >> >> >> But when I’d tried access like: >> >> >> >> http://localhost:8080/test >> >> or >> >> http://localhost:8080/home >> >> >> >> Don’t work, What is wrong? >> >> >> >> My config file: >> >> >> >> { >> >> >> >> "service" : { >> >> "api" : "http", >> >> "port" : 8080, >> >> "worker_threads" : 20, >> >> >> >> }, >> >> "http" : { >> >> "script" : "/" >> >> }, >> >> "file_server" : { >> >> "enable" : true >> >> }, >> >> "session" : { >> >> "expire" : "renew", >> >> "timeout" : 604800, >> >> "location" : "client", >> >> "client" : { >> >> "encryptor" : "hmac", >> >> "key" : >> "232074faa0fd37de20858bf8cd0a7d04" >> >> } >> >> }, >> >> } >> >> >> >> Thaks >> >> --------------------------------------------------------------------- >> - >> -------- Enable your software for Intel(R) Active Management >> Technology to meet the growing manageability and security demands of >> your customers. Businesses are taking advantage of Intel(R) vPro (TM) >> technology - will your software be a part of the solution? Download >> the Intel(R) Manageability Checker today! >> http://p.sf.net/sfu/intel-dev2devmar >> _______________________________________________ >> Cppcms-users mailing list >> Cpp...@li... >> https://lists.sourceforge.net/lists/listinfo/cppcms-users >> >> > ---------------------------------------------------------------------- > -------- Enable your software for Intel(R) Active Management > Technology to meet the growing manageability and security demands of > your customers. Businesses are taking advantage of Intel(R) vPro (TM) > technology - will your software be a part of the solution? Download > the Intel(R) Manageability Checker today! > http://p.sf.net/sfu/intel-dev2devmar > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > ---------------------------------------------------------------------- > -------- Enable your software for Intel(R) Active Management > Technology to meet the growing manageability and security demands of > your customers. Businesses are taking advantage of Intel(R) vPro (TM) > technology - will your software be a part of the solution? Download > the Intel(R) Manageability Checker today! > http://p.sf.net/sfu/intel-dev2devmar > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > ------------------------------------------------------------------------------ Enable your software for Intel(R) Active Management Technology to meet the growing manageability and security demands of your customers. Businesses are taking advantage of Intel(R) vPro (TM) technology - will your software be a part of the solution? Download the Intel(R) Manageability Checker today! http://p.sf.net/sfu/intel-dev2devmar _______________________________________________ Cppcms-users mailing list Cpp...@li... https://lists.sourceforge.net/lists/listinfo/cppcms-users |
From: Artyom <art...@ya...> - 2011-03-26 09:13:34
|
Hello, First of all I'll try to explain. Generally your web server, apache, lighttpd, nginx and all others map some script name to the FastCGI application and serve all other static files. So for example if you have directory like /project/root /project/root/media/my.css /project/root/images/mypic.png And then to distinguish between the application and the static files so called script name is provided. So we give let's say script name "/myapp" then everything like http://server/myapp http://server/myapp/page/cool/1034 http://server/myapp/something/else Would be passed to the application, while everything else (static files) would be server by the web server, and it is very-very good in it. Now when URL like http://server/myapp/page/cool/1034 Is serverd It is divided into CGI variables: HTTP_HOST server SCRIPT_NAME /myapp PATH_INFO /page/cool/1034 Now dispatching by default works with PATH_INFO which is generally the best option. So you need to do URL mapping against it. So in this configuration. document_root is "/project/root" - local file system script is "/myapp" And you should map like "/page/.*" You can take a look as a good example the message_board in new 0.99.7 release. Now setting "/" as script is bad idea as it passes everything to the application and you don't want it as it forces you to serve static content (and you don't want to) You can make URLs like http://host/page/cool/1023 And http://host/media/my.css Work using URL rewriting provided by all modern real web servers, however such things are not supported by the internal web server which is suitable for debugging only. (Ohhh I need to add this to CppCMS's wiki as it is quite common question). So in your case it should be "http" : { "script" : "/portal", }, And matching: add(_test, "/test((/.*))?",2); // first match - from test/foo -> extracts "/foo" for // URL http://host/portal/test/foo add(_portal, "(.*)", 1); // match everything else // extracts "/bar" from "/bar for URL http://host/portal/bar Artyom ----- Original Message ---- > From: Renato Forti <re....@ay...> > To: cpp...@li... > Sent: Fri, March 25, 2011 5:56:58 PM > Subject: [Cppcms-users] RES: RES: URL maps > > Thanks for help, > > How config file should be to work? > > This is what I have: > > { > "vws" : { > "media" : "/media", > "root" : "/vws", > "host" : "localhost:8080", > "connection-string-dir" : >"E:\\project.vgsws\\resources\\connection-strings" > }, > "service" : { > "api" : "http", > "port" : 8080, > "worker_threads" : 20, > > }, > "http" : { > "script" : "/", > "script_names" : [ "/test", "/portal" ] > }, > "file_server" : { > "enable" : true > }, > "session" : { > "expire" : "renew", > "timeout" : 604800, > "location" : "client", > "client" : { > "encryptor" : "hmac", > "key" : "232074faa0fd37de20858bf8cd0a7d04" > } > }, > } > > And in class: > > class App : public cppcms::application > { > public: > > Test _test; > Portal _portal; > > App(cppcms::service &s) > : cppcms::application(s) > , _test(s) > , _portal(s) > { > add(_test, "/test", 1); > add(_portal, "/portal", 1); > } > }; > > Thank you very much, for help. > > > -----Mensagem original----- > De: Cristian Oneț [mailto:one...@gm...] > Enviada em: sexta-feira, 25 de março de 2011 12:29 > Para: cpp...@li... > Assunto: Re: [Cppcms-users] RES: URL maps > > It does not work because you application is mounted at '/' and your >sub-applications at '/test' and '/home' and that's relative to your parent >application's mountpoint. So after '/' is matched for your main application you >will only have 'test' (not '/test') or 'home' (not > '/home') left from the url to match and it will not match. > > On Fri, Mar 25, 2011 at 4:57 PM, Renato Forti <re....@ay...> wrote: > > Like this: > > > > "http" : { > > "script_names" : [ "/test", "/ home " ] > > }, > > > > :o(, I did try, but don't work... > > > > Any tip? > > > > Thanks, thanks, thanks... > > > > -----Mensagem original----- > > De: Cristian Oneț [mailto:one...@gm...] Enviada em: > > sexta-feira, 25 de março de 2011 11:53 > > Para: cpp...@li... > > Assunto: Re: [Cppcms-users] URL maps > > > > I think that your problem is that "/test" and "/home" are missing from the >scripts section of the configuration file. > > > > On Fri, Mar 25, 2011 at 3:15 PM, Renato Forti <re....@ay...> wrote: > >> Hi, > >> > >> > >> > >> I am try understand how group and map url. > >> > >> > >> > >> For sample I have 2 classes: > >> > >> > >> > >> class Home : public cppcms::application > >> > >> class Test : public cppcms::application > >> > >> > >> > >> And a class that I can group apps: > >> > >> > >> > >> class App : public cppcms::application > >> > >> { > >> > >> public: > >> > >> > >> > >> Home _home; > >> > >> Test _test; > >> > >> > >> > >> App(cppcms::service &s) > >> > >> : cppcms::application(s) > >> > >> , _home(s) > >> > >> , _test(s) > >> > >> { > >> > >> add(_test, "/test", 1); > >> > >> add(_home, "/home", 2); > >> > >> } > >> > >> }; > >> > >> > >> > >> > >> > >> > >> > >> int main(int argc,char ** argv) > >> > >> { > >> > >> try > >> > >> { > >> > >> cppcms::service srv(argc, argv); > >> > >> srv.applications_pool().mount(cppcms::applications_factory<App>()); > >> > >> srv.run(); > >> > >> } > >> > >> catch(std::exception const &e) > >> > >> { > >> > >> std::cerr<<e.what()<<std::endl; > >> > >> } > >> > >> } > >> > >> > >> > >> But when I’d tried access like: > >> > >> > >> > >> http://localhost:8080/test > >> > >> or > >> > >> http://localhost:8080/home > >> > >> > >> > >> Don’t work, What is wrong? > >> > >> > >> > >> My config file: > >> > >> > >> > >> { > >> > >> > >> > >> "service" : { > >> > >> "api" : "http", > >> > >> "port" : 8080, > >> > >> "worker_threads" : 20, > >> > >> > >> > >> }, > >> > >> "http" : { > >> > >> "script" : "/" > >> > >> }, > >> > >> "file_server" : { > >> > >> "enable" : true > >> > >> }, > >> > >> "session" : { > >> > >> "expire" : "renew", > >> > >> "timeout" : 604800, > >> > >> "location" : "client", > >> > >> "client" : { > >> > >> "encryptor" : "hmac", > >> > >> "key" : > >> "232074faa0fd37de20858bf8cd0a7d04" > >> > >> } > >> > >> }, > >> > >> } > >> > >> > >> > >> Thaks > >> > >> --------------------------------------------------------------------- > >> - > >> -------- Enable your software for Intel(R) Active Management > >> Technology to meet the growing manageability and security demands of > >> your customers. Businesses are taking advantage of Intel(R) vPro (TM) > >> technology - will your software be a part of the solution? Download > >> the Intel(R) Manageability Checker today! > >> http://p.sf.net/sfu/intel-dev2devmar > >> _______________________________________________ > >> Cppcms-users mailing list > >> Cpp...@li... > >> https://lists.sourceforge.net/lists/listinfo/cppcms-users > >> > >> > > ---------------------------------------------------------------------- > > -------- Enable your software for Intel(R) Active Management > > Technology to meet the growing manageability and security demands of > > your customers. Businesses are taking advantage of Intel(R) vPro (TM) > > technology - will your software be a part of the solution? Download > > the Intel(R) Manageability Checker today! > > http://p.sf.net/sfu/intel-dev2devmar > > _______________________________________________ > > Cppcms-users mailing list > > Cpp...@li... > > https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > > > > ---------------------------------------------------------------------- > > -------- Enable your software for Intel(R) Active Management > > Technology to meet the growing manageability and security demands of > > your customers. Businesses are taking advantage of Intel(R) vPro (TM) > > technology - will your software be a part of the solution? Download > > the Intel(R) Manageability Checker today! > > http://p.sf.net/sfu/intel-dev2devmar > > _______________________________________________ > > Cppcms-users mailing list > > Cpp...@li... > > https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > > ------------------------------------------------------------------------------ > Enable your software for Intel(R) Active Management Technology to meet the >growing manageability and security demands of your customers. Businesses are >taking advantage of Intel(R) vPro (TM) technology - will your software be a >part of the solution? Download the Intel(R) Manageability Checker today! >http://p.sf.net/sfu/intel-dev2devmar > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > ------------------------------------------------------------------------------ > Enable your software for Intel(R) Active Management Technology to meet the > growing manageability and security demands of your customers. Businesses > are taking advantage of Intel(R) vPro (TM) technology - will your software > be a part of the solution? Download the Intel(R) Manageability Checker > today! http://p.sf.net/sfu/intel-dev2devmar > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > |
From: Renato F. <re....@ay...> - 2011-03-26 13:49:23
|
Hi Artyom, Thanks for the class, really you should put this information on wiki is very good and clear. Now I will upgrade my version to CppCMS 0.99.7 and put sessions to work. :0) Thanks, I 'am very impressed: CppCMS is a great project, and its fills a hole in C++ development (C++ Web Development). -----Mensagem original----- De: Artyom [mailto:art...@ya...] Enviada em: sábado, 26 de março de 2011 06:13 Para: cpp...@li... Assunto: Re: [Cppcms-users] RES: RES: URL maps Hello, First of all I'll try to explain. Generally your web server, apache, lighttpd, nginx and all others map some script name to the FastCGI application and serve all other static files. So for example if you have directory like /project/root /project/root/media/my.css /project/root/images/mypic.png And then to distinguish between the application and the static files so called script name is provided. So we give let's say script name "/myapp" then everything like http://server/myapp http://server/myapp/page/cool/1034 http://server/myapp/something/else Would be passed to the application, while everything else (static files) would be server by the web server, and it is very-very good in it. Now when URL like http://server/myapp/page/cool/1034 Is serverd It is divided into CGI variables: HTTP_HOST server SCRIPT_NAME /myapp PATH_INFO /page/cool/1034 Now dispatching by default works with PATH_INFO which is generally the best option. So you need to do URL mapping against it. So in this configuration. document_root is "/project/root" - local file system script is "/myapp" And you should map like "/page/.*" You can take a look as a good example the message_board in new 0.99.7 release. Now setting "/" as script is bad idea as it passes everything to the application and you don't want it as it forces you to serve static content (and you don't want to) You can make URLs like http://host/page/cool/1023 And http://host/media/my.css Work using URL rewriting provided by all modern real web servers, however such things are not supported by the internal web server which is suitable for debugging only. (Ohhh I need to add this to CppCMS's wiki as it is quite common question). So in your case it should be "http" : { "script" : "/portal", }, And matching: add(_test, "/test((/.*))?",2); // first match - from test/foo -> extracts "/foo" for // URL http://host/portal/test/foo add(_portal, "(.*)", 1); // match everything else // extracts "/bar" from "/bar for URL http://host/portal/bar Artyom ----- Original Message ---- > From: Renato Forti <re....@ay...> > To: cpp...@li... > Sent: Fri, March 25, 2011 5:56:58 PM > Subject: [Cppcms-users] RES: RES: URL maps > > Thanks for help, > > How config file should be to work? > > This is what I have: > > { > "vws" : { > "media" : "/media", > "root" : "/vws", > "host" : "localhost:8080", > "connection-string-dir" : >"E:\\project.vgsws\\resources\\connection-strings" > }, > "service" : { > "api" : "http", > "port" : 8080, > "worker_threads" : 20, > > }, > "http" : { > "script" : "/", > "script_names" : [ "/test", "/portal" ] > }, > "file_server" : { > "enable" : true > }, > "session" : { > "expire" : "renew", > "timeout" : 604800, > "location" : "client", > "client" : { > "encryptor" : "hmac", > "key" : "232074faa0fd37de20858bf8cd0a7d04" > } > }, > } > > And in class: > > class App : public cppcms::application { > public: > > Test _test; > Portal _portal; > > App(cppcms::service &s) > : cppcms::application(s) > , _test(s) > , _portal(s) > { > add(_test, "/test", 1); > add(_portal, "/portal", 1); > } > }; > > Thank you very much, for help. > > > -----Mensagem original----- > De: Cristian Oneț [mailto:one...@gm...] Enviada em: > sexta-feira, 25 de março de 2011 12:29 > Para: cpp...@li... > Assunto: Re: [Cppcms-users] RES: URL maps > > It does not work because you application is mounted at '/' and your >sub-applications at '/test' and '/home' and that's relative to your >parent application's mountpoint. So after '/' is matched for your main >application you will only have 'test' (not '/test') or 'home' (not > '/home') left from the url to match and it will not match. > > On Fri, Mar 25, 2011 at 4:57 PM, Renato Forti <re....@ay...> wrote: > > Like this: > > > > "http" : { > > "script_names" : [ "/test", "/ home " ] > > }, > > > > :o(, I did try, but don't work... > > > > Any tip? > > > > Thanks, thanks, thanks... > > > > -----Mensagem original----- > > De: Cristian Oneț [mailto:one...@gm...] Enviada em: > > sexta-feira, 25 de março de 2011 11:53 > > Para: cpp...@li... > > Assunto: Re: [Cppcms-users] URL maps > > > > I think that your problem is that "/test" and "/home" are missing > > from the >scripts section of the configuration file. > > > > On Fri, Mar 25, 2011 at 3:15 PM, Renato Forti > > <re....@ay...> wrote: > >> Hi, > >> > >> > >> > >> I am try understand how group and map url. > >> > >> > >> > >> For sample I have 2 classes: > >> > >> > >> > >> class Home : public cppcms::application > >> > >> class Test : public cppcms::application > >> > >> > >> > >> And a class that I can group apps: > >> > >> > >> > >> class App : public cppcms::application > >> > >> { > >> > >> public: > >> > >> > >> > >> Home _home; > >> > >> Test _test; > >> > >> > >> > >> App(cppcms::service &s) > >> > >> : cppcms::application(s) > >> > >> , _home(s) > >> > >> , _test(s) > >> > >> { > >> > >> add(_test, "/test", 1); > >> > >> add(_home, "/home", 2); > >> > >> } > >> > >> }; > >> > >> > >> > >> > >> > >> > >> > >> int main(int argc,char ** argv) > >> > >> { > >> > >> try > >> > >> { > >> > >> cppcms::service srv(argc, argv); > >> > >> > >> srv.applications_pool().mount(cppcms::applications_factory<App>()); > >> > >> srv.run(); > >> > >> } > >> > >> catch(std::exception const &e) > >> > >> { > >> > >> std::cerr<<e.what()<<std::endl; > >> > >> } > >> > >> } > >> > >> > >> > >> But when I’d tried access like: > >> > >> > >> > >> http://localhost:8080/test > >> > >> or > >> > >> http://localhost:8080/home > >> > >> > >> > >> Don’t work, What is wrong? > >> > >> > >> > >> My config file: > >> > >> > >> > >> { > >> > >> > >> > >> "service" : { > >> > >> "api" : "http", > >> > >> "port" : 8080, > >> > >> "worker_threads" : 20, > >> > >> > >> > >> }, > >> > >> "http" : { > >> > >> "script" : "/" > >> > >> }, > >> > >> "file_server" : { > >> > >> "enable" : true > >> > >> }, > >> > >> "session" : { > >> > >> "expire" : "renew", > >> > >> "timeout" : 604800, > >> > >> "location" : "client", > >> > >> "client" : { > >> > >> "encryptor" : > >> "hmac", > >> > >> "key" : > >> "232074faa0fd37de20858bf8cd0a7d04" > >> > >> } > >> > >> }, > >> > >> } > >> > >> > >> > >> Thaks > >> > >> > >> ------------------------------------------------------------------- > >> -- > >> - > >> -------- Enable your software for Intel(R) Active Management > >> Technology to meet the growing manageability and security demands > >> of your customers. Businesses are taking advantage of Intel(R) vPro > >> (TM) technology - will your software be a part of the solution? > >> Download the Intel(R) Manageability Checker today! > >> http://p.sf.net/sfu/intel-dev2devmar > >> _______________________________________________ > >> Cppcms-users mailing list > >> Cpp...@li... > >> https://lists.sourceforge.net/lists/listinfo/cppcms-users > >> > >> > > > > -------------------------------------------------------------------- > > -- > > -------- Enable your software for Intel(R) Active Management > > Technology to meet the growing manageability and security demands > > of your customers. Businesses are taking advantage of Intel(R) vPro > > (TM) technology - will your software be a part of the solution? > > Download the Intel(R) Manageability Checker today! > > http://p.sf.net/sfu/intel-dev2devmar > > _______________________________________________ > > Cppcms-users mailing list > > Cpp...@li... > > https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > > > > > > -------------------------------------------------------------------- > > -- > > -------- Enable your software for Intel(R) Active Management > > Technology to meet the growing manageability and security demands > > of your customers. Businesses are taking advantage of Intel(R) vPro > > (TM) technology - will your software be a part of the solution? > > Download the Intel(R) Manageability Checker today! > > http://p.sf.net/sfu/intel-dev2devmar > > _______________________________________________ > > Cppcms-users mailing list > > Cpp...@li... > > https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > > >----------------------------------------------------------------------- >------- Enable your software for Intel(R) Active Management >Technology to meet the growing manageability and security demands of >your customers. Businesses are taking advantage of Intel(R) vPro (TM) >technology - will your software be a part of the solution? Download >the Intel(R) Manageability Checker today! >http://p.sf.net/sfu/intel-dev2devmar > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > ---------------------------------------------------------------------- > -------- Enable your software for Intel(R) Active Management > Technology to meet the growing manageability and security demands of > your customers. Businesses are taking advantage of Intel(R) vPro (TM) > technology - will your software be a part of the solution? Download > the Intel(R) Manageability Checker today! > http://p.sf.net/sfu/intel-dev2devmar > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > ------------------------------------------------------------------------------ Enable your software for Intel(R) Active Management Technology to meet the growing manageability and security demands of your customers. Businesses are taking advantage of Intel(R) vPro (TM) technology - will your software be a part of the solution? Download the Intel(R) Manageability Checker today! http://p.sf.net/sfu/intel-dev2devmar _______________________________________________ Cppcms-users mailing list Cpp...@li... https://lists.sourceforge.net/lists/listinfo/cppcms-users |