Maurice Grönwoldt
5bb68a7d02
We have no make install support... so we don't need to have everything as a single-header and lib file.
37 lines
936 B
C++
37 lines
936 B
C++
#include "VWeb-1.0/VWeb.h"
|
|
|
|
class MyCompleteController : public VWeb::Route {
|
|
public:
|
|
bool Get(const VWeb::Request&, VWeb::Response& response) {
|
|
response << "MyCompleteController: GET";
|
|
return true;
|
|
}
|
|
bool Post(const VWeb::Request&, VWeb::Response& response) {
|
|
response << "MyCompleteController: POST";
|
|
return true;
|
|
}
|
|
|
|
bool IsAllowed(const VWeb::Request& request) {
|
|
return request.HasHeader("Auth");
|
|
}
|
|
};
|
|
bool Ping(const VWeb::Request&, VWeb::Response& response) {
|
|
response << "Pong";
|
|
return true;
|
|
}
|
|
int main() {
|
|
using namespace VWeb;
|
|
VWeb::Server server;
|
|
auto& router = server.GetRouter();
|
|
// For debugging and profiling more than 1 thread can be hard.
|
|
server.GetServerConfig()->WorkerThreads = 1;
|
|
router->Get("/test", [](const Request&, Response& response) {
|
|
response << "NICE";
|
|
return true;
|
|
});
|
|
router->Get("/ping", &Ping);
|
|
server.Start();
|
|
server.Join();
|
|
return 0;
|
|
}
|