67 lines
1.5 KiB
C++
67 lines
1.5 KiB
C++
#ifndef __RESTFUL_H__
|
|
#define __RESTFUL_H__
|
|
|
|
#include <Wt/Dbo/Session.h>
|
|
#include <Wt/Dbo/Types.h>
|
|
#include <Wt/WResource.h>
|
|
#include <random>
|
|
|
|
class MyMessage {
|
|
public:
|
|
std::string message;
|
|
|
|
template <class Action>
|
|
void persist(Action &a) {
|
|
Wt::Dbo::field(a, message, "message");
|
|
}
|
|
};
|
|
|
|
class World {
|
|
public:
|
|
int randomNumber;
|
|
|
|
template <class Action>
|
|
void persist(Action &a) {
|
|
Wt::Dbo::field(a, randomNumber, "randomnumber");
|
|
}
|
|
};
|
|
|
|
class Fortune {
|
|
public:
|
|
std::string message;
|
|
|
|
template <class Action>
|
|
void persist(Action &a) {
|
|
Wt::Dbo::field(a, message, "message");
|
|
}
|
|
};
|
|
|
|
struct DbStruct {
|
|
DbStruct(const std::string &db);
|
|
int rand();
|
|
Wt::Dbo::Session session;
|
|
std::default_random_engine rng;
|
|
std::uniform_int_distribution<int> distribution;
|
|
};
|
|
|
|
class AuthenticationResource : public Wt::WResource {
|
|
public:
|
|
AuthenticationResource(Wt::Dbo::SqlConnectionPool &connectionPool);
|
|
void handleRequest(const Wt::Http::Request &request, Wt::Http::Response &response) final;
|
|
|
|
private:
|
|
Wt::Dbo::SqlConnectionPool &m_connectionPool;
|
|
};
|
|
|
|
class PlaintextResource : public Wt::WResource {
|
|
public:
|
|
void handleRequest(const Wt::Http::Request &request, Wt::Http::Response &response) final;
|
|
};
|
|
|
|
class DbResource : public Wt::WResource {
|
|
public:
|
|
DbResource(const std::string &db);
|
|
void handleRequest(const Wt::Http::Request &request, Wt::Http::Response &response) final;
|
|
};
|
|
|
|
#endif // __RESTFUL_H__
|