> Tommi Mäkitalo <[email protected]> hat am 4. Oktober 2013 um 23:31 geschrieben:
[....]
> Please explain, why you really need full paths in your links? If you
> just change the domain name, the application have to behave differently.
In my solution, the domain name is generated in runtime. So if is the
configuration change than the domain name is change automatically in
rum time.
> If I link to a page in my application, it must always point to the same
> protocol, same host and same port. There is no need to specify the full
> path.
The work with protocol is not a problem. In my solution it is check
this in runtime. But yes, the explicit switch you mast programming
a explicit url, but only for the switch.
I don't know a case where the web application is switch host and port
address. If it is tow different applications - yes, than you need
a classic external link.
> It even makes it difficult to test your application since you may
> test the application on a different host than it runs on.
In my solution with map using (not the static const char variation)
the host name, port and protocol is generating to rum time in
discrepancy of application configuration.
> It is even better to use relative paths. The application may run behind
> a proxy, which adds a subdirectory. But that is another case.
Yes this is a important point! I remember me, I hat trouble with Zope/Plone
CMS. Plone is use or generating absolute pathes.
>
> But what I always expect is to have as less C++ code as possible in the
> view. You may want to change the href to:
>
> <a href="<$ url::RSSfeedview() $>">
>
> Then you can write a function "RSSfeedview", which does whatever you
> want. The function can either just return a string or something like:
> std::string RSSfeedview()
> {
> cxxtools::net::Uri uri; // there is a nice Uri-classin cxxtools
> uri.host("www.somewhere.else");
> uri.protocol("http");
> uri.port(80);
> uri.path("/rss.xml");
> return uri.str();
> }
Okay, but this is not a solution for using flexible host, protocol and
port. It would better when read this part from a configuration class or
from tnt::HttpRequest and that is what I'm doing here:
https://github.com/OlafRadicke/peruschim_cpp/blob/feature_trustet_user/src/RouteReverse/manager/Manager.cpp
But what we can do is, counting the "/" in the tnt::HttpRequest::getUrl()
an generating a relative path like this - for example:
<a href="../../../../../dir/subdir/subsubdir/subsubsubdir/targetComponent">
So no more handling with domain, port and protocol, but no static const char
too.
Gratings,
Olaf
-------------------|-------------------|-------------------|-------------------|
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
_______________________________________________
Tntnet-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tntnet-general