main.cpp 1009 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include <cppcms/service.h>
  2. #include <cppcms/applications_pool.h>
  3. #include <cppcms/http_response.h>
  4. #include <cppcms/url_dispatcher.h>
  5. #include <iostream>
  6. #include "test_simple.h"
  7. #include "test_fortunes.h"
  8. #include "test_db.h"
  9. class myapp : public cppcms::application {
  10. public:
  11. myapp(cppcms::service &srv) : cppcms::application(srv) {
  12. attach(new test_simple(srv), "/json()", 0);
  13. attach(new test_simple(srv), "/plaintext()", 0);
  14. attach(new test_fortunes(srv), "/fortunes()", 1);
  15. attach(new test_db(srv), "/db()", 0);
  16. attach(new test_db(srv), "/queries/.*", 0);
  17. attach(new test_db(srv), "/updates/.*", 0);
  18. attach(new test_db(srv), "/cached-worlds/.*", 0);
  19. }
  20. };
  21. int main(int argc, char **argv) {
  22. try {
  23. cppcms::service app(argc, argv);
  24. app.applications_pool().mount(cppcms::applications_factory<myapp>());
  25. app.run();
  26. } catch (std::exception const &e) {
  27. std::cerr << e.what() << std::endl;
  28. }
  29. }