38 lines
1.1 KiB
C++
38 lines
1.1 KiB
C++
#include "VWeb-1.0/VWeb.h"
|
|
|
|
class MyCompleteController : public VWeb::Route {
|
|
public:
|
|
bool Get(VWeb::Request &req, VWeb::Response &response) override {
|
|
response << "MyCompleteController: GET:: \r\n\r\nParameters:\r\n\r\n";
|
|
for (auto &[key, value] : req.URLParameters) {
|
|
response << key << ": " << value << "\r\n";
|
|
}
|
|
return true;
|
|
}
|
|
bool Post(VWeb::Request &, VWeb::Response &response) override {
|
|
response << "MyCompleteController: POST";
|
|
return true;
|
|
}
|
|
};
|
|
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", [](Request &, Response &response) {
|
|
response << "NICE";
|
|
return true;
|
|
});
|
|
router->Get("/ping", &Ping);
|
|
router->Register<MyCompleteController>("/auth/:id/",
|
|
HttpMethod::GET | HttpMethod::POST);
|
|
server.Start();
|
|
server.Join();
|
|
return 0;
|
|
}
|