1
0
Fork 0
forked from blue/pica

some thinking around passing the form

This commit is contained in:
Blue 2023-12-14 19:17:28 -03:00
parent 3fe6d25448
commit 0c50cfa639
Signed by untrusted user: blue
GPG key ID: 9B203B252A63EE38
9 changed files with 149 additions and 0 deletions

View file

@ -2,12 +2,14 @@ set(HEADERS
handler.h
info.h
env.h
register.h
)
set(SOURCES
handler.cpp
info.cpp
env.cpp
register.cpp
)
target_sources(${PROJECT_NAME} PRIVATE ${SOURCES})

23
handler/register.cpp Normal file
View file

@ -0,0 +1,23 @@
// SPDX-FileCopyrightText: 2023 Yury Gubich <blue@macaw.me>
// SPDX-License-Identifier: GPL-3.0-or-later
#include "register.h"
Handler::Register::Register():
Handler("register", Request::Method::post)
{}
void Handler::Register::handle(Request& request) {
std::map form = request.getForm();
std::cout << "Received form:" << std::endl;
for (const auto& pair : form)
std::cout << '\t' << pair.first << ": " << pair.second << std::endl;
Response res(request);
nlohmann::json body = nlohmann::json::object();
body["result"] = "ok";
res.setBody(body);
res.send();
}

16
handler/register.h Normal file
View file

@ -0,0 +1,16 @@
// SPDX-FileCopyrightText: 2023 Yury Gubich <blue@macaw.me>
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
#include "handler.h"
namespace Handler {
class Register : public Handler::Handler {
public:
Register();
virtual void handle(Request& request);
};
}