add auth api.
All checks were successful
Deploy / Build (push) Successful in 4m46s

This commit is contained in:
luocai 2024-11-14 21:53:18 +08:00
parent 130ae630aa
commit 3392f8a0b3
3 changed files with 3 additions and 3 deletions

View File

@ -8,7 +8,7 @@ DBO_INSTANTIATE_TEMPLATES(MyMessage)
DbStruct *m_dbStruct; DbStruct *m_dbStruct;
void JsonResource::handleRequest(const Wt::Http::Request &request, Wt::Http::Response &response) { void AuthenticationResource::handleRequest(const Wt::Http::Request &request, Wt::Http::Response &response) {
response.setMimeType("application/json"); response.setMimeType("application/json");
response.addHeader("Server", "Wt"); response.addHeader("Server", "Wt");

View File

@ -44,7 +44,7 @@ struct DbStruct {
std::uniform_int_distribution<int> distribution; std::uniform_int_distribution<int> distribution;
}; };
class JsonResource : public Wt::WResource { class AuthenticationResource : public Wt::WResource {
public: public:
void handleRequest(const Wt::Http::Request &request, Wt::Http::Response &response) final; void handleRequest(const Wt::Http::Request &request, Wt::Http::Response &response) final;
}; };

View File

@ -30,7 +30,7 @@ WebApplication::WebApplication() {
m_server = std::make_unique<Wt::WServer>("./build", args); m_server = std::make_unique<Wt::WServer>("./build", args);
m_server->addEntryPoint(Wt::EntryPointType::Application, createApplication, "/hello"); m_server->addEntryPoint(Wt::EntryPointType::Application, createApplication, "/hello");
m_server->addEntryPoint(Wt::EntryPointType::WidgetSet, createWidgetSet, "/gui/hello.js"); m_server->addEntryPoint(Wt::EntryPointType::WidgetSet, createWidgetSet, "/gui/hello.js");
m_server->addResource(std::make_shared<JsonResource>(), "/json"); m_server->addResource(std::make_shared<AuthenticationResource>(), "/auth");
m_server->addResource(std::make_shared<PlaintextResource>(), "/plaintext"); m_server->addResource(std::make_shared<PlaintextResource>(), "/plaintext");
m_server->addResource(std::make_shared<DbResource>("database.sqlite"), "/db"); m_server->addResource(std::make_shared<DbResource>("database.sqlite"), "/db");