#include <cppcms/application.h>
#include <cppcms/service.h>
#include <cppcms/http_response.h>
#include <cppcms/url_dispatcher.h>
#include <cppcms/url_mapper.h>
#include <cppcms/applications_pool.h>
#include <iostream>
#include <stdlib.h>
public:
{
}
void all()
{
<<
"<a href='" <<
url(
"/") <<
"'>Top</a><br>" <<
"<a href='" <<
url(
"/letters")<<
"'>Letters</a><br>" <<
"<a href='" <<
url(
".") <<
"'>All Numbers</a><br>" <<
"<a href='" <<
url(
"odd") <<
"'>Odd Numbers</a><br>" <<
"<a href='" <<
url(
"even") <<
"'>Even Numbers</a><br>" <<
"<a href='" <<
url(
"prime") <<
"'>Prime Numbers</a><br>" << "1,2,3,4,5,6,7,8,9,10,...";
}
void prime()
{
}
void odd()
{
}
void even()
{
}
};
public:
{
dispatcher().assign("",&letters::all,this);
mapper().assign("");
dispatcher().assign("/capital",&letters::capital,this);
mapper().assign("capital","/capital");
dispatcher().assign("/small",&letters::small,this);
mapper().assign("small","/small");
}
void all()
{
response().out()
<< "<a href='" << url("/") << "'>Top</a><br>"
<< "<a href='" << url("/numbers")<< "'>Numbers</a><br>"
<< "<a href='" << url(".") << "'>All Letters</a><br>"
<< "<a href='" << url("capital") << "'>Capital Letters</a><br>"
<< "<a href='" << url("small") << "'>Small Letters</a><br>"
<< "Aa, Bb, Cc, Dd,...";
}
void capital()
{
response().out() << "A,B,C,D,...";
}
void small()
{
response().out() << "a,b,c,d,...";
}
};
public:
{
attach( new numbers(srv),
"numbers", "/numbers{1}",
"/numbers(/(.*))?", 1);
attach( new letters(srv),
"letters", "/letters{1}",
"/letters(/(.*))?", 1);
dispatcher().assign("",&myapp::describe,this);
mapper().assign("");
mapper().root("/myapp");
}
void describe()
{
response().out()
<< "<a href='" << url("/numbers")<< "'>Numbers</a><br>"
<< "<a href='" << url("/letters")<< "'>Letters</a><br>"
<< "<a href='" << url("/numbers/odd")<< "'>Odd Numbers</a><br>";
}
};
int main(int argc,char ** argv)
{
try {
app.applications_pool().mount(cppcms::applications_factory<myapp>());
app.run();
}
catch(std::exception const &e) {
std::cerr<<e.what()<<std::endl;
}
}