VWeb/example/main.cpp

35 lines
815 B
C++

#include <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();
router->Get("/test", [](const Request&, Response& response) {
response << "NICE";
return true;
});
router->Get("/ping", &Ping);
server.Start();
server.Join();
return 0;
}