Thread: [Cppcms-users] CppCMS-Embedded web root
Brought to you by:
artyom-beilis
From: Rodrigo E. <rod...@gm...> - 2016-02-10 18:02:53
|
Hi Everyone, I am trying a simple example with CppCms and I would like to execute all my applications relative to the web application root. I don't want execute the application relative to the script path. Ex localhost: 8080/script-path/relative-path-to-my-application, and instead of this, I would like the path for my application would be like: localhost: 8080/relative-path-to-my-application. I would like to execute this application using the CppCMS-Embedded. I am trying a super simple example and I had no success. All the time I try the root url ( http://localhost:8080/) I get a 404 error like that: Connection close Content-Encoding gzip Content-Type text/html; charset=utf-8 Server CppCMS-Embedded/1.1.0 X-Powered-By CppCMS/1.1.0 status 404 Not Found Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Encoding gzip, deflate Accept-Language en-US,en;q=0.5 Cache-Control max-age=0 Connection keep-alive Cookie _ga=GA1.1.541474771.1454701631 Host localhost:8080 User-Agent Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:44.0) Gecko/20100101 Firefox/44.0 Below the config.js of my example: config.js: { "http" : { "script" : "/mb.fcgi", "rewrite" : [ { "regex" : "/media(/.*)?", "pattern" : "$0" }, { "regex" : ".*" , "pattern" : "/mb.fcgi$0" } ] }, "service": { "api":"http", "port":8080 }, "views" : { "paths" : [ "./" ], "skins" : [ "my_app"], },} What's I missing in my configurations? Why the CppCMS-Embedded is not routing for the web application root . Thanks. Rodrigo |
From: Stanimir M. <sta...@zo...> - 2016-02-10 20:53:59
|
Hello Rodrigo, Did you try this documentation http://cppcms.com/wikipp/en/page/run_application_web_server_root#CppCMS-Embedded If it didn't help, then try to put this line in the constructor of your my_app (the one that inherited from cppcms::application) mapper().root(""); See here http://cppcms.com/wikipp/en/page/cppcms_1x_tut_url_mapping#Mapping On Wed, Feb 10, 2016 at 8:02 PM, Rodrigo Emygdio <rod...@gm...> wrote: > Hi Everyone, > > I am trying a simple example with CppCms and I would like to execute all my > applications relative to the web application root. I don't want execute the > application relative to the script path. Ex localhost: > 8080/script-path/relative-path-to-my-application, and instead of this, I > would like the path for my application would be like: localhost: > 8080/relative-path-to-my-application. I would like to execute this > application using the CppCMS-Embedded. I am trying a super simple example > and I had no success. All the time I try the root url > (http://localhost:8080/) I get a 404 error like that: > > > Connection close > > Content-Encoding gzip > > Content-Type text/html; charset=utf-8 > > Server CppCMS-Embedded/1.1.0 > > X-Powered-By CppCMS/1.1.0 > > status 404 Not Found > > Accept > text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 > > Accept-Encoding gzip, deflate > > Accept-Language en-US,en;q=0.5 > > Cache-Control max-age=0 > > Connection keep-alive > > Cookie _ga=GA1.1.541474771.1454701631 > > Host localhost:8080 > > User-Agent Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:44.0) > Gecko/20100101 Firefox/44.0 > > Below the config.js of my example: > > > config.js: > > { > "http" : { > "script" : "/mb.fcgi", > "rewrite" : [ > { "regex" : "/media(/.*)?", "pattern" : "$0" }, > { "regex" : ".*" , "pattern" : "/mb.fcgi$0" } > ] > }, > "service": { > "api":"http", > "port":8080 > }, > "views" : { > "paths" : [ "./" ], > "skins" : [ "my_app"], > }, > } > > > What's I missing in my configurations? Why the CppCMS-Embedded is not > routing for the web application root . > > Thanks. > > Rodrigo > > > > ------------------------------------------------------------------------------ > Site24x7 APM Insight: Get Deep Visibility into Application Performance > APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month > Monitor end-to-end web transactions and take corrective actions now > Troubleshoot faster and improve end-user experience. Signup Now! > http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140 > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > |
From: Rodrigo E. <rod...@gm...> - 2016-02-10 22:18:07
|
HI Stanimir, First, thank you very much for your feedback . Yes, I did read both of these documentations. Below have the main class of the example that I'm trying to execute: #include <cppcms/application.h>#include <cppcms/applications_pool.h>#include <cppcms/service.h>#include <cppcms/http_response.h>#include <cppcms/url_dispatcher.h>#include <cppcms/url_mapper.h>#include <iostream>#include "content.h" class my_app : public cppcms::application{ public: my_app(cppcms::service& s) : cppcms::application(s){ dispatcher().assign("",&my_app::well_come,this); mapper().assign(""); mapper().root(""); } void well_come(){ content::index ci; ci.message = "Hello "; render("index",ci); } }; int main(int argc,char ** argv){ try{ cppcms::service srv(argc,argv); srv.applications_pool().mount( cppcms::applications_factory<my_app>() ); srv.run(); }catch(std::exception const & e){ std::cerr<<e.what()<<std::endl; }} Thanks, Rodrigo 2016-02-10 18:28 GMT-02:00 Stanimir Mladenov < sta...@zo...>: > Hello Rodrigo, > > Did you try this documentation > > http://cppcms.com/wikipp/en/page/run_application_web_server_root#CppCMS-Embedded > If it didn't help, then try to put this line in the constructor of > your my_app (the one that inherited from cppcms::application) > > mapper().root(""); > > See here > http://cppcms.com/wikipp/en/page/cppcms_1x_tut_url_mapping#Mapping > > On Wed, Feb 10, 2016 at 8:02 PM, Rodrigo Emygdio > <rod...@gm...> wrote: > > Hi Everyone, > > > > I am trying a simple example with CppCms and I would like to execute all > my > > applications relative to the web application root. I don't want execute > the > > application relative to the script path. Ex localhost: > > 8080/script-path/relative-path-to-my-application, and instead of this, I > > would like the path for my application would be like: localhost: > > 8080/relative-path-to-my-application. I would like to execute this > > application using the CppCMS-Embedded. I am trying a super simple example > > and I had no success. All the time I try the root url > > (http://localhost:8080/) I get a 404 error like that: > > > > > > Connection close > > > > Content-Encoding gzip > > > > Content-Type text/html; charset=utf-8 > > > > Server CppCMS-Embedded/1.1.0 > > > > X-Powered-By CppCMS/1.1.0 > > > > status 404 Not Found > > > > Accept > > text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 > > > > Accept-Encoding gzip, deflate > > > > Accept-Language en-US,en;q=0.5 > > > > Cache-Control max-age=0 > > > > Connection keep-alive > > > > Cookie _ga=GA1.1.541474771.1454701631 > > > > Host localhost:8080 > > > > User-Agent Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:44.0) > > Gecko/20100101 Firefox/44.0 > > > > Below the config.js of my example: > > > > > > config.js: > > > > { > > "http" : { > > "script" : "/mb.fcgi", > > "rewrite" : [ > > { "regex" : "/media(/.*)?", "pattern" : "$0" }, > > { "regex" : ".*" , "pattern" : "/mb.fcgi$0" } > > ] > > }, > > "service": { > > "api":"http", > > "port":8080 > > }, > > "views" : { > > "paths" : [ "./" ], > > "skins" : [ "my_app"], > > }, > > } > > > > > > What's I missing in my configurations? Why the CppCMS-Embedded is not > > routing for the web application root . > > > > Thanks. > > > > Rodrigo > > > > > > > > > ------------------------------------------------------------------------------ > > Site24x7 APM Insight: Get Deep Visibility into Application Performance > > APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month > > Monitor end-to-end web transactions and take corrective actions now > > Troubleshoot faster and improve end-user experience. Signup Now! > > http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140 > > _______________________________________________ > > Cppcms-users mailing list > > Cpp...@li... > > https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > > > ------------------------------------------------------------------------------ > Site24x7 APM Insight: Get Deep Visibility into Application Performance > APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month > Monitor end-to-end web transactions and take corrective actions now > Troubleshoot faster and improve end-user experience. Signup Now! > http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140 > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > |
From: Artyom B. <art...@gm...> - 2016-02-11 08:10:59
|
> class my_app : public cppcms::application{ > public: > my_app(cppcms::service& s) : cppcms::application(s){ > dispatcher().assign("",&my_app::well_come,this); > mapper().assign(""); > mapper().root(""); > } 1st check if cppcms::application::main is called (I think it should) it is virtual member function so you can override it. 2nd When you access to "localhost:8080" you get request GET / HTTP/1.0 it is mapped according to the rules to /mb.fcgi/ Than /mb.fcgi is matched and the path you get is "/" When you map to "" you Require empty path and thus it does not get dispatched. The correct is always to map to something starting with "/" or map to "/?" i.e. last "/" is optional. You can also use little bit different rule Instead of this { "regex" : ".*" , "pattern" : "/mb.fcgi$0" } Use { "regex" : "/(.*)" , "pattern" : "/mb.fcgi$1" } Than none of your urls will start from "/" it does not matter how do you do it - just pic and convention and stick to it. Artyom |
From: Rodrigo E. <rod...@gm...> - 2016-02-11 22:56:46
|
Hi Artyom, Thanks very much for your feedback. I tested the virtual main method and is executing properly. I changed the regex and the root url works very well. The problem now is that any other url just works if I add an extra "/" on the begin on the path. Thanks 2016-02-11 6:10 GMT-02:00 Artyom Beilis <art...@gm...>: > > class my_app : public cppcms::application{ > > public: > > my_app(cppcms::service& s) : cppcms::application(s){ > > dispatcher().assign("",&my_app::well_come,this); > > mapper().assign(""); > > mapper().root(""); > > } > > 1st check if cppcms::application::main is called (I think it should) > it is virtual > member function so you can override it. > > 2nd When you access to "localhost:8080" you get request GET / HTTP/1.0 > it is mapped according to the rules to > > /mb.fcgi/ > > Than /mb.fcgi is matched and the path you get is "/" > > When you map to "" you Require empty path and thus it does not get > dispatched. > > The correct is always to map to something starting with "/" or map to > "/?" i.e. last "/" is optional. > > > You can also use little bit different rule > > Instead of this > > { "regex" : ".*" , "pattern" : "/mb.fcgi$0" } > > Use > > { "regex" : "/(.*)" , "pattern" : "/mb.fcgi$1" } > > Than none of your urls will start from "/" > > it does not matter how do you do it - just pic and convention and stick to > it. > > Artyom > > > ------------------------------------------------------------------------------ > Site24x7 APM Insight: Get Deep Visibility into Application Performance > APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month > Monitor end-to-end web transactions and take corrective actions now > Troubleshoot faster and improve end-user experience. Signup Now! > http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140 > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > |
From: Rodrigo E. <rod...@gm...> - 2016-02-12 04:14:24
|
I think that I need to explain better what I would like expect from the CppCms. I have a little application that I wrote in Java and have specific urls indexed by google: http://domain.com/ --> reflects the main page http://domain.com/[others-pretty-url] --> reflects each functions of the application. The application urls were indexed by google, and I don't want to lose these urls. I need to rewrite this application in C++ and I decided to use CppCms. Then I expect to use the same URLs as were indexed by Google. The main page need to responds the root url (http://domain.com/) and the other urls need respond like pretty urls (http://domain.com/some-pretty-url). I did as Artyom tells me to do. Changing the rewrite rules as below: change: { "regex" : ".*" , "pattern" : "/mb.fcgi$0" } for this: { "regex" : "/(.*)" , "pattern" : "/mb.fcgi$1"} Immediately resolved the problem with the root url, but the rest of urls stop to work because the server takes the part after the "/" and concatenates with the /mb.fcgi. Unhappily there isn't any url with no "/" before them. I tried overcome that changing the dispatcher configuration of the url, like that: I changed this: dispatcher().assign("/contact-form",&my_app::contact_form,this); mapper().assign("contact_form","/contact-form"); For this: dispatcher().assign("contact-form",&my_app::contact_form,this); mapper().assign("contact_form","contact-form"); Unhappily this changing didn't work. Anybody has some idea how I can resolve that. Thanks 2016-02-11 20:56 GMT-02:00 Rodrigo Emygdio <rod...@gm...>: > Hi Artyom, > > Thanks very much for your feedback. I tested the virtual main method and > is executing properly. I changed the regex and the root url works very > well. The problem now is that any other url just works if I add an extra > "/" on the begin on the path. > > Thanks > > 2016-02-11 6:10 GMT-02:00 Artyom Beilis <art...@gm...>: > >> > class my_app : public cppcms::application{ >> > public: >> > my_app(cppcms::service& s) : cppcms::application(s){ >> > dispatcher().assign("",&my_app::well_come,this); >> > mapper().assign(""); >> > mapper().root(""); >> > } >> >> 1st check if cppcms::application::main is called (I think it should) >> it is virtual >> member function so you can override it. >> >> 2nd When you access to "localhost:8080" you get request GET / HTTP/1.0 >> it is mapped according to the rules to >> >> /mb.fcgi/ >> >> Than /mb.fcgi is matched and the path you get is "/" >> >> When you map to "" you Require empty path and thus it does not get >> dispatched. >> >> The correct is always to map to something starting with "/" or map to >> "/?" i.e. last "/" is optional. >> >> >> You can also use little bit different rule >> >> Instead of this >> >> { "regex" : ".*" , "pattern" : "/mb.fcgi$0" } >> >> Use >> >> { "regex" : "/(.*)" , "pattern" : "/mb.fcgi$1" } >> >> Than none of your urls will start from "/" >> >> it does not matter how do you do it - just pic and convention and stick >> to it. >> >> Artyom >> >> >> ------------------------------------------------------------------------------ >> Site24x7 APM Insight: Get Deep Visibility into Application Performance >> APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month >> Monitor end-to-end web transactions and take corrective actions now >> Troubleshoot faster and improve end-user experience. Signup Now! >> http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140 >> _______________________________________________ >> Cppcms-users mailing list >> Cpp...@li... >> https://lists.sourceforge.net/lists/listinfo/cppcms-users >> > > |
From: Rodrigo E. <rod...@gm...> - 2016-02-12 17:15:01
|
Hi Everyone, I decided to give up CppCMS-Embedded and fight with the lighttpd. I configured the lighttpd to execute the application in the "root" of the web service with the following configuration: server.port = 8080 server.bind = "127.0.0.1" fastcgi.server = ( "/" => ( "localhost" => ( "bin-path" => "/home/emygdio/Documents/Estudo/Progamacao/C++/CppCms/RootWebServer/hello -c /home/emygdio/Documents/Estudo/Progamacao/C++/CppCms/RootWebServer/etc/config-lighthttpd-2.js", "socket" => "/tmp/hello-fcgi-socket", "fix-root-scriptname" => "enable", "check-local" => "disable", ))) The pretty urls work very well, like http://domain.com/some-pretty-url. But the empty router like this http://domain.com/, still doesn't work. Any assist will be very welcome Thanks 2016-02-12 2:14 GMT-02:00 Rodrigo Emygdio <rod...@gm...>: > I think that I need to explain better what I would like expect from the > CppCms. I have a little application that I wrote in Java and have specific > urls indexed by google: > http://domain.com/ --> reflects the main page > http://domain.com/[others-pretty-url] --> reflects each functions of > the application. > The application urls were indexed by google, and I don't want to lose > these urls. I need to rewrite this application in C++ and I decided to use > CppCms. Then I expect to use the same URLs as were indexed by Google. The > main page need to responds the root url (http://domain.com/) and the > other urls need respond like pretty urls ( > http://domain.com/some-pretty-url). > > I did as Artyom tells me to do. Changing the rewrite rules as below: > > change: > > { "regex" : ".*" , "pattern" : "/mb.fcgi$0" } > > for this: > > { "regex" : "/(.*)" , "pattern" : "/mb.fcgi$1"} > > Immediately resolved the problem with the root url, but the rest of urls > stop to work because the server takes the part after the "/" and > concatenates with the /mb.fcgi. Unhappily there isn't any url with no "/" > before them. > I tried overcome that changing the dispatcher configuration of the url, > like that: > > I changed this: > dispatcher().assign("/contact-form",&my_app::contact_form,this); > mapper().assign("contact_form","/contact-form"); > > For this: > dispatcher().assign("contact-form",&my_app::contact_form,this); > mapper().assign("contact_form","contact-form"); > > Unhappily this changing didn't work. > > Anybody has some idea how I can resolve that. > Thanks > > 2016-02-11 20:56 GMT-02:00 Rodrigo Emygdio <rod...@gm...>: > >> Hi Artyom, >> >> Thanks very much for your feedback. I tested the virtual main method and >> is executing properly. I changed the regex and the root url works very >> well. The problem now is that any other url just works if I add an extra >> "/" on the begin on the path. >> >> Thanks >> >> 2016-02-11 6:10 GMT-02:00 Artyom Beilis <art...@gm...>: >> >>> > class my_app : public cppcms::application{ >>> > public: >>> > my_app(cppcms::service& s) : cppcms::application(s){ >>> > dispatcher().assign("",&my_app::well_come,this); >>> > mapper().assign(""); >>> > mapper().root(""); >>> > } >>> >>> 1st check if cppcms::application::main is called (I think it should) >>> it is virtual >>> member function so you can override it. >>> >>> 2nd When you access to "localhost:8080" you get request GET / HTTP/1.0 >>> it is mapped according to the rules to >>> >>> /mb.fcgi/ >>> >>> Than /mb.fcgi is matched and the path you get is "/" >>> >>> When you map to "" you Require empty path and thus it does not get >>> dispatched. >>> >>> The correct is always to map to something starting with "/" or map to >>> "/?" i.e. last "/" is optional. >>> >>> >>> You can also use little bit different rule >>> >>> Instead of this >>> >>> { "regex" : ".*" , "pattern" : "/mb.fcgi$0" } >>> >>> Use >>> >>> { "regex" : "/(.*)" , "pattern" : "/mb.fcgi$1" } >>> >>> Than none of your urls will start from "/" >>> >>> it does not matter how do you do it - just pic and convention and stick >>> to it. >>> >>> Artyom >>> >>> >>> ------------------------------------------------------------------------------ >>> Site24x7 APM Insight: Get Deep Visibility into Application Performance >>> APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month >>> Monitor end-to-end web transactions and take corrective actions now >>> Troubleshoot faster and improve end-user experience. Signup Now! >>> http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140 >>> _______________________________________________ >>> Cppcms-users mailing list >>> Cpp...@li... >>> https://lists.sourceforge.net/lists/listinfo/cppcms-users >>> >> >> > |
From: Rodrigo E. <rod...@gm...> - 2016-02-15 17:19:50
|
Hi Everyone, First of all, I would like to thanks the fast feedback of Stanimir and good explanation that Artyom Beilis did. I am glad to say that this *thread was resolved*. With base on the Artyom's explanation I understood how the routing of urls works. I resolved my problem in this way: First, I created index route that is the main page: dispatcher().assign("/index",&site::index,this); mapper().assign("index","/index"); And all the other url I created in the same form: dispatcher().assign("/contact-form",&site::contact_form,this); mapper().assign("contact_form","/contact-form"); dispatcher().assign("/do-something,&site::something,this); mapper().assign("something","/do-something"); To accomplish my objective, I used two regex for the rewrite url rules, like that: { "regex" : "/()" , "pattern" : "/mb.fcgi/index" }, { "regex" : ".*" , "pattern" : "/mb.fcgi$0" } The first one, does the route for url with "/" and empty urls ( http://domain.com/ and http://domain.com). And the second executes the rest of the urls (http://domain.com/contact-form and http://domain.com/do-something). I hope this thread may help another person with the same doubt Best Regard 2016-02-12 15:14 GMT-02:00 Rodrigo Emygdio <rod...@gm...>: > Hi Everyone, > > I decided to give up CppCMS-Embedded and fight with the lighttpd. I > configured the lighttpd to execute the application in the "root" of the web > service with the following configuration: > > server.port = 8080 > server.bind = "127.0.0.1" > > fastcgi.server = ( "/" => ( "localhost" => ( > "bin-path" => > "/home/emygdio/Documents/Estudo/Progamacao/C++/CppCms/RootWebServer/hello > -c > /home/emygdio/Documents/Estudo/Progamacao/C++/CppCms/RootWebServer/etc/config-lighthttpd-2.js", > "socket" => "/tmp/hello-fcgi-socket", > "fix-root-scriptname" => "enable", > "check-local" => "disable", > ))) > > The pretty urls work very well, like http://domain.com/some-pretty-url. > But the empty router like this http://domain.com/, still doesn't work. > > Any assist will be very welcome > > Thanks > > > 2016-02-12 2:14 GMT-02:00 Rodrigo Emygdio <rod...@gm...>: > >> I think that I need to explain better what I would like expect from the >> CppCms. I have a little application that I wrote in Java and have specific >> urls indexed by google: >> http://domain.com/ --> reflects the main page >> http://domain.com/[others-pretty-url] --> reflects each functions of >> the application. >> The application urls were indexed by google, and I don't want to lose >> these urls. I need to rewrite this application in C++ and I decided to use >> CppCms. Then I expect to use the same URLs as were indexed by Google. The >> main page need to responds the root url (http://domain.com/) and the >> other urls need respond like pretty urls ( >> http://domain.com/some-pretty-url). >> >> I did as Artyom tells me to do. Changing the rewrite rules as below: >> >> change: >> >> { "regex" : ".*" , "pattern" : "/mb.fcgi$0" } >> >> for this: >> >> { "regex" : "/(.*)" , "pattern" : "/mb.fcgi$1"} >> >> Immediately resolved the problem with the root url, but the rest of urls >> stop to work because the server takes the part after the "/" and >> concatenates with the /mb.fcgi. Unhappily there isn't any url with no "/" >> before them. >> I tried overcome that changing the dispatcher configuration of the url, >> like that: >> >> I changed this: >> dispatcher().assign("/contact-form",&my_app::contact_form,this); >> mapper().assign("contact_form","/contact-form"); >> >> For this: >> dispatcher().assign("contact-form",&my_app::contact_form,this); >> mapper().assign("contact_form","contact-form"); >> >> Unhappily this changing didn't work. >> >> Anybody has some idea how I can resolve that. >> Thanks >> >> 2016-02-11 20:56 GMT-02:00 Rodrigo Emygdio <rod...@gm...>: >> >>> Hi Artyom, >>> >>> Thanks very much for your feedback. I tested the virtual main method and >>> is executing properly. I changed the regex and the root url works very >>> well. The problem now is that any other url just works if I add an extra >>> "/" on the begin on the path. >>> >>> Thanks >>> >>> 2016-02-11 6:10 GMT-02:00 Artyom Beilis <art...@gm...>: >>> >>>> > class my_app : public cppcms::application{ >>>> > public: >>>> > my_app(cppcms::service& s) : cppcms::application(s){ >>>> > dispatcher().assign("",&my_app::well_come,this); >>>> > mapper().assign(""); >>>> > mapper().root(""); >>>> > } >>>> >>>> 1st check if cppcms::application::main is called (I think it should) >>>> it is virtual >>>> member function so you can override it. >>>> >>>> 2nd When you access to "localhost:8080" you get request GET / HTTP/1.0 >>>> it is mapped according to the rules to >>>> >>>> /mb.fcgi/ >>>> >>>> Than /mb.fcgi is matched and the path you get is "/" >>>> >>>> When you map to "" you Require empty path and thus it does not get >>>> dispatched. >>>> >>>> The correct is always to map to something starting with "/" or map to >>>> "/?" i.e. last "/" is optional. >>>> >>>> >>>> You can also use little bit different rule >>>> >>>> Instead of this >>>> >>>> { "regex" : ".*" , "pattern" : "/mb.fcgi$0" } >>>> >>>> Use >>>> >>>> { "regex" : "/(.*)" , "pattern" : "/mb.fcgi$1" } >>>> >>>> Than none of your urls will start from "/" >>>> >>>> it does not matter how do you do it - just pic and convention and stick >>>> to it. >>>> >>>> Artyom >>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> Site24x7 APM Insight: Get Deep Visibility into Application Performance >>>> APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month >>>> Monitor end-to-end web transactions and take corrective actions now >>>> Troubleshoot faster and improve end-user experience. Signup Now! >>>> http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140 >>>> _______________________________________________ >>>> Cppcms-users mailing list >>>> Cpp...@li... >>>> https://lists.sourceforge.net/lists/listinfo/cppcms-users >>>> >>> >>> >> > |
From: Artyom B. <art...@gm...> - 2016-02-16 12:29:29
|
Wouldn't instead of { "regex" : "/()" , "pattern" : "/mb.fcgi/index" }, dispatcher().assign("/index",&site::index,this); The following would work out of the box dispatcher().assign("/",&site::index,this); i.e. without this specific pattern. On Mon, Feb 15, 2016 at 7:19 PM, Rodrigo Emygdio <rod...@gm...> wrote: > Hi Everyone, > > First of all, I would like to thanks the fast feedback of Stanimir and good > explanation that Artyom Beilis did. I am glad to say that this thread was > resolved. > With base on the Artyom's explanation I understood how the routing of urls > works. > I resolved my problem in this way: > First, I created index route that is the main page: > > dispatcher().assign("/index",&site::index,this); > mapper().assign("index","/index"); > > And all the other url I created in the same form: > > dispatcher().assign("/contact-form",&site::contact_form,this); > mapper().assign("contact_form","/contact-form"); > > dispatcher().assign("/do-something,&site::something,this); > mapper().assign("something","/do-something"); > > > To accomplish my objective, I used two regex for the rewrite url rules, like > that: > > { "regex" : "/()" , "pattern" : "/mb.fcgi/index" }, > { "regex" : ".*" , "pattern" : "/mb.fcgi$0" } > > The first one, does the route for url with "/" and empty urls > (http://domain.com/ and http://domain.com). And the second executes the rest > of the urls (http://domain.com/contact-form and > http://domain.com/do-something). > > I hope this thread may help another person with the same doubt > > Best Regard > > 2016-02-12 15:14 GMT-02:00 Rodrigo Emygdio <rod...@gm...>: >> >> Hi Everyone, >> >> I decided to give up CppCMS-Embedded and fight with the lighttpd. I >> configured the lighttpd to execute the application in the "root" of the web >> service with the following configuration: >> >> server.port = 8080 >> server.bind = "127.0.0.1" >> >> fastcgi.server = ( "/" => ( "localhost" => ( >> "bin-path" => >> "/home/emygdio/Documents/Estudo/Progamacao/C++/CppCms/RootWebServer/hello -c >> /home/emygdio/Documents/Estudo/Progamacao/C++/CppCms/RootWebServer/etc/config-lighthttpd-2.js", >> "socket" => "/tmp/hello-fcgi-socket", >> "fix-root-scriptname" => "enable", >> "check-local" => "disable", >> ))) >> >> The pretty urls work very well, like http://domain.com/some-pretty-url. >> But the empty router like this http://domain.com/, still doesn't work. >> >> Any assist will be very welcome >> >> Thanks >> >> >> 2016-02-12 2:14 GMT-02:00 Rodrigo Emygdio <rod...@gm...>: >>> >>> I think that I need to explain better what I would like expect from the >>> CppCms. I have a little application that I wrote in Java and have specific >>> urls indexed by google: >>> http://domain.com/ --> reflects the main page >>> http://domain.com/[others-pretty-url] --> reflects each functions of >>> the application. >>> The application urls were indexed by google, and I don't want to lose >>> these urls. I need to rewrite this application in C++ and I decided to use >>> CppCms. Then I expect to use the same URLs as were indexed by Google. The >>> main page need to responds the root url (http://domain.com/) and the other >>> urls need respond like pretty urls (http://domain.com/some-pretty-url). >>> >>> I did as Artyom tells me to do. Changing the rewrite rules as below: >>> >>> change: >>> >>> { "regex" : ".*" , "pattern" : "/mb.fcgi$0" } >>> >>> for this: >>> >>> { "regex" : "/(.*)" , "pattern" : "/mb.fcgi$1"} >>> >>> Immediately resolved the problem with the root url, but the rest of urls >>> stop to work because the server takes the part after the "/" and >>> concatenates with the /mb.fcgi. Unhappily there isn't any url with no "/" >>> before them. >>> I tried overcome that changing the dispatcher configuration of the url, >>> like that: >>> >>> I changed this: >>> dispatcher().assign("/contact-form",&my_app::contact_form,this); >>> mapper().assign("contact_form","/contact-form"); >>> >>> For this: >>> dispatcher().assign("contact-form",&my_app::contact_form,this); >>> mapper().assign("contact_form","contact-form"); >>> >>> Unhappily this changing didn't work. >>> >>> Anybody has some idea how I can resolve that. >>> Thanks >>> >>> 2016-02-11 20:56 GMT-02:00 Rodrigo Emygdio <rod...@gm...>: >>>> >>>> Hi Artyom, >>>> >>>> Thanks very much for your feedback. I tested the virtual main method and >>>> is executing properly. I changed the regex and the root url works very well. >>>> The problem now is that any other url just works if I add an extra "/" on >>>> the begin on the path. >>>> >>>> Thanks >>>> >>>> 2016-02-11 6:10 GMT-02:00 Artyom Beilis <art...@gm...>: >>>>> >>>>> > class my_app : public cppcms::application{ >>>>> > public: >>>>> > my_app(cppcms::service& s) : cppcms::application(s){ >>>>> > dispatcher().assign("",&my_app::well_come,this); >>>>> > mapper().assign(""); >>>>> > mapper().root(""); >>>>> > } >>>>> >>>>> 1st check if cppcms::application::main is called (I think it should) >>>>> it is virtual >>>>> member function so you can override it. >>>>> >>>>> 2nd When you access to "localhost:8080" you get request GET / HTTP/1.0 >>>>> it is mapped according to the rules to >>>>> >>>>> /mb.fcgi/ >>>>> >>>>> Than /mb.fcgi is matched and the path you get is "/" >>>>> >>>>> When you map to "" you Require empty path and thus it does not get >>>>> dispatched. >>>>> >>>>> The correct is always to map to something starting with "/" or map to >>>>> "/?" i.e. last "/" is optional. >>>>> >>>>> >>>>> You can also use little bit different rule >>>>> >>>>> Instead of this >>>>> >>>>> { "regex" : ".*" , "pattern" : "/mb.fcgi$0" } >>>>> >>>>> Use >>>>> >>>>> { "regex" : "/(.*)" , "pattern" : "/mb.fcgi$1" } >>>>> >>>>> Than none of your urls will start from "/" >>>>> >>>>> it does not matter how do you do it - just pic and convention and stick >>>>> to it. >>>>> >>>>> Artyom >>>>> >>>>> >>>>> ------------------------------------------------------------------------------ >>>>> Site24x7 APM Insight: Get Deep Visibility into Application Performance >>>>> APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month >>>>> Monitor end-to-end web transactions and take corrective actions now >>>>> Troubleshoot faster and improve end-user experience. Signup Now! >>>>> http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140 >>>>> _______________________________________________ >>>>> Cppcms-users mailing list >>>>> Cpp...@li... >>>>> https://lists.sourceforge.net/lists/listinfo/cppcms-users >>>> >>>> >>> >> > > > ------------------------------------------------------------------------------ > Site24x7 APM Insight: Get Deep Visibility into Application Performance > APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month > Monitor end-to-end web transactions and take corrective actions now > Troubleshoot faster and improve end-user experience. Signup Now! > http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140 > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > |
From: Rodrigo E. <rod...@gm...> - 2016-02-16 13:03:53
|
Hi Artyom, Thanks again, this solution works much better and more straightforward . 2016-02-16 10:29 GMT-02:00 Artyom Beilis <art...@gm...>: > Wouldn't instead of > > { "regex" : "/()" , "pattern" : "/mb.fcgi/index" }, > dispatcher().assign("/index",&site::index,this); > > The following would work out of the box > > dispatcher().assign("/",&site::index,this); > > i.e. without this specific pattern. > > On Mon, Feb 15, 2016 at 7:19 PM, Rodrigo Emygdio > <rod...@gm...> wrote: > > Hi Everyone, > > > > First of all, I would like to thanks the fast feedback of Stanimir and > good > > explanation that Artyom Beilis did. I am glad to say that this thread was > > resolved. > > With base on the Artyom's explanation I understood how the routing of > urls > > works. > > I resolved my problem in this way: > > First, I created index route that is the main page: > > > > dispatcher().assign("/index",&site::index,this); > > mapper().assign("index","/index"); > > > > And all the other url I created in the same form: > > > > dispatcher().assign("/contact-form",&site::contact_form,this); > > mapper().assign("contact_form","/contact-form"); > > > > dispatcher().assign("/do-something,&site::something,this); > > mapper().assign("something","/do-something"); > > > > > > To accomplish my objective, I used two regex for the rewrite url rules, > like > > that: > > > > { "regex" : "/()" , "pattern" : "/mb.fcgi/index" }, > > { "regex" : ".*" , "pattern" : "/mb.fcgi$0" } > > > > The first one, does the route for url with "/" and empty urls > > (http://domain.com/ and http://domain.com). And the second executes the > rest > > of the urls (http://domain.com/contact-form and > > http://domain.com/do-something). > > > > I hope this thread may help another person with the same doubt > > > > Best Regard > > > > 2016-02-12 15:14 GMT-02:00 Rodrigo Emygdio <rod...@gm...>: > >> > >> Hi Everyone, > >> > >> I decided to give up CppCMS-Embedded and fight with the lighttpd. I > >> configured the lighttpd to execute the application in the "root" of the > web > >> service with the following configuration: > >> > >> server.port = 8080 > >> server.bind = "127.0.0.1" > >> > >> fastcgi.server = ( "/" => ( "localhost" => ( > >> "bin-path" => > >> > "/home/emygdio/Documents/Estudo/Progamacao/C++/CppCms/RootWebServer/hello -c > >> > /home/emygdio/Documents/Estudo/Progamacao/C++/CppCms/RootWebServer/etc/config-lighthttpd-2.js", > >> "socket" => "/tmp/hello-fcgi-socket", > >> "fix-root-scriptname" => "enable", > >> "check-local" => "disable", > >> ))) > >> > >> The pretty urls work very well, like http://domain.com/some-pretty-url. > >> But the empty router like this http://domain.com/, still doesn't work. > >> > >> Any assist will be very welcome > >> > >> Thanks > >> > >> > >> 2016-02-12 2:14 GMT-02:00 Rodrigo Emygdio <rod...@gm...>: > >>> > >>> I think that I need to explain better what I would like expect from the > >>> CppCms. I have a little application that I wrote in Java and have > specific > >>> urls indexed by google: > >>> http://domain.com/ --> reflects the main page > >>> http://domain.com/[others-pretty-url] --> reflects each functions > of > >>> the application. > >>> The application urls were indexed by google, and I don't want to lose > >>> these urls. I need to rewrite this application in C++ and I decided to > use > >>> CppCms. Then I expect to use the same URLs as were indexed by Google. > The > >>> main page need to responds the root url (http://domain.com/) and the > other > >>> urls need respond like pretty urls (http://domain.com/some-pretty-url > ). > >>> > >>> I did as Artyom tells me to do. Changing the rewrite rules as below: > >>> > >>> change: > >>> > >>> { "regex" : ".*" , "pattern" : "/mb.fcgi$0" } > >>> > >>> for this: > >>> > >>> { "regex" : "/(.*)" , "pattern" : "/mb.fcgi$1"} > >>> > >>> Immediately resolved the problem with the root url, but the rest of > urls > >>> stop to work because the server takes the part after the "/" and > >>> concatenates with the /mb.fcgi. Unhappily there isn't any url with no > "/" > >>> before them. > >>> I tried overcome that changing the dispatcher configuration of the > url, > >>> like that: > >>> > >>> I changed this: > >>> dispatcher().assign("/contact-form",&my_app::contact_form,this); > >>> mapper().assign("contact_form","/contact-form"); > >>> > >>> For this: > >>> dispatcher().assign("contact-form",&my_app::contact_form,this); > >>> mapper().assign("contact_form","contact-form"); > >>> > >>> Unhappily this changing didn't work. > >>> > >>> Anybody has some idea how I can resolve that. > >>> Thanks > >>> > >>> 2016-02-11 20:56 GMT-02:00 Rodrigo Emygdio <rod...@gm... > >: > >>>> > >>>> Hi Artyom, > >>>> > >>>> Thanks very much for your feedback. I tested the virtual main method > and > >>>> is executing properly. I changed the regex and the root url works > very well. > >>>> The problem now is that any other url just works if I add an extra > "/" on > >>>> the begin on the path. > >>>> > >>>> Thanks > >>>> > >>>> 2016-02-11 6:10 GMT-02:00 Artyom Beilis <art...@gm...>: > >>>>> > >>>>> > class my_app : public cppcms::application{ > >>>>> > public: > >>>>> > my_app(cppcms::service& s) : cppcms::application(s){ > >>>>> > dispatcher().assign("",&my_app::well_come,this); > >>>>> > mapper().assign(""); > >>>>> > mapper().root(""); > >>>>> > } > >>>>> > >>>>> 1st check if cppcms::application::main is called (I think it should) > >>>>> it is virtual > >>>>> member function so you can override it. > >>>>> > >>>>> 2nd When you access to "localhost:8080" you get request GET / > HTTP/1.0 > >>>>> it is mapped according to the rules to > >>>>> > >>>>> /mb.fcgi/ > >>>>> > >>>>> Than /mb.fcgi is matched and the path you get is "/" > >>>>> > >>>>> When you map to "" you Require empty path and thus it does not get > >>>>> dispatched. > >>>>> > >>>>> The correct is always to map to something starting with "/" or map to > >>>>> "/?" i.e. last "/" is optional. > >>>>> > >>>>> > >>>>> You can also use little bit different rule > >>>>> > >>>>> Instead of this > >>>>> > >>>>> { "regex" : ".*" , "pattern" : "/mb.fcgi$0" } > >>>>> > >>>>> Use > >>>>> > >>>>> { "regex" : "/(.*)" , "pattern" : "/mb.fcgi$1" } > >>>>> > >>>>> Than none of your urls will start from "/" > >>>>> > >>>>> it does not matter how do you do it - just pic and convention and > stick > >>>>> to it. > >>>>> > >>>>> Artyom > >>>>> > >>>>> > >>>>> > ------------------------------------------------------------------------------ > >>>>> Site24x7 APM Insight: Get Deep Visibility into Application > Performance > >>>>> APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month > >>>>> Monitor end-to-end web transactions and take corrective actions now > >>>>> Troubleshoot faster and improve end-user experience. Signup Now! > >>>>> http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140 > >>>>> _______________________________________________ > >>>>> Cppcms-users mailing list > >>>>> Cpp...@li... > >>>>> https://lists.sourceforge.net/lists/listinfo/cppcms-users > >>>> > >>>> > >>> > >> > > > > > > > ------------------------------------------------------------------------------ > > Site24x7 APM Insight: Get Deep Visibility into Application Performance > > APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month > > Monitor end-to-end web transactions and take corrective actions now > > Troubleshoot faster and improve end-user experience. Signup Now! > > http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140 > > _______________________________________________ > > Cppcms-users mailing list > > Cpp...@li... > > https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > > > ------------------------------------------------------------------------------ > Site24x7 APM Insight: Get Deep Visibility into Application Performance > APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month > Monitor end-to-end web transactions and take corrective actions now > Troubleshoot faster and improve end-user experience. Signup Now! > http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140 > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > |