Re: [Cppcms-users] CppCMS-Embedded web root
Brought to you by:
artyom-beilis
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 > |