Older/WebApplication/Restful.h

54 lines
1.1 KiB
C
Raw Normal View History

2024-11-01 19:05:20 +08:00
#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:
2025-01-03 22:17:45 +08:00
int status = 0;
2024-11-01 19:05:20 +08:00
std::string message;
2024-12-26 23:10:41 +08:00
std::string user;
2024-11-01 19:05:20 +08:00
template <class Action>
void persist(Action &a) {
2025-01-03 22:17:45 +08:00
Wt::Dbo::field(a, status, "status");
2024-11-01 19:05:20 +08:00
Wt::Dbo::field(a, message, "message");
2024-12-26 23:10:41 +08:00
Wt::Dbo::field(a, user, "user");
2024-11-01 19:05:20 +08:00
}
};
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");
}
};
2024-11-14 21:53:18 +08:00
class AuthenticationResource : public Wt::WResource {
2024-11-01 19:05:20 +08:00
public:
2024-11-26 22:58:54 +08:00
AuthenticationResource();
2024-11-01 19:05:20 +08:00
void handleRequest(const Wt::Http::Request &request, Wt::Http::Response &response) final;
};
class PlaintextResource : public Wt::WResource {
public:
void handleRequest(const Wt::Http::Request &request, Wt::Http::Response &response) final;
};
#endif // __RESTFUL_H__