I needed a docRoot per URL, this is what I came up with, tested and it
works, but is there a better way?
Hack in WApplication.c
std::string WApplication::docRoot() const
{
/*** FIXIT Hackit here. ***
*
*/
std::string myDR = environment().getCgiValue("DOCUMENT_ROOT");
std::string myCDR = "doc_root";
// Get host Name
WApplication *app = WApplication::instance();
std::string domainName = app->environment().hostName().c_str();
// Remove Port if it exist
unsigned pos = domainName.find(":");
if (pos > 0)
domainName = domainName.substr(0, pos);
// Now do a look up
if (!readConfigurationProperty("customDocRoot-" + domainName,
myCDR))
Wt::log("warning") << "WApplication::docRoot()
readConfigurationProperty not found customDocRoot-" << domainName << "
in wt_config.xml";
// if its not empy and does not end with a slash, add one
if (!myCDR.empty() && myCDR[myCDR.length()-1] != '/')
myCDR += '/';
if (myCDR.empty())
return myDR.c_str();
else
return myCDR.c_str();
}
in wt_config.xml
<property name="customDocRoot-localhost">/path/doc_root/</property>
<property name="customDocRoot-domain.tdl">/path/doc_root/</property>
Now that works fine for docRoot(), but where does the application get
and set docRoot from?
My guess would be Configuration.C in folder http
void Configuration::readOptions(const po::variables_map& vm)
if (vm.count("docroot"))
If so, what is the easies way to do the same thing here to get the
hostName, and read in the config path,
this crashes, but like I said, I still do not understand how to create
an instance of app outside a class derived from WApplication without it
crashing
// Get host Name
Wt::WApplication *app = Wt::WApplication::instance();
//MyApplication* myapp =
boost::polymorphic_downcast(app);
std::string domainName =
app->environment().hostName().c_str();
// Remove Port if it exist
unsigned pos = domainName.find(":");
if (pos > 0)
domainName = domainName.substr(0, pos);
// Now do a look up
if (!
Wt::WApplication::readConfigurationProperty("customDocRoot-" +
domainName, myCDR))
Wt::log("error") << "WApplication::docRoot()
readConfigurationProperty not found customDocRoot-" << domainName << "
in wt_config.xml";
// if its not empy and does not end with a slash, add
one
if (!myCDR.empty() && myCDR[myCDR.length()-1] != '/')
myCDR += '/';
if (!myCDR.empty())
docRoot_ = myCDR.c_str();
Note: Running an application per URL is not very efficient, in testing
on a VPS,
I could not run many apps at the same time without slamming the servers
resources, mostly PostgreeSQL,
so I want to do this from one app.
Thanks
------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest