daster/source/requests/server.d

31 lines
863 B
D
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

module requests.server;
import vibe.vibe;
import response;
import structures;
import sql;
import singlog;
import std.regex;
// Получить информацию о сервере
void getServerInfo(HTTPServerRequest req, HTTPServerResponse res) {
auto dataServer = sqlGetServerInfo();
render!("server.dt", dataServer)(res);
}
void sendWriteServerInfo(HTTPServerRequest req, HTTPServerResponse res) {
ServerDB server = deserializeJson!ServerDB(req.json);
if (!server.external_number.matchFirst(regex(r"^\+7\d{10}$", "g"))) {
res.send(true, "Внешний номер не соответствует формату +7XXXXXXXXXX");
return;
}
if (!sqlUpdateServerInfo(server)) {
res.send(true, "Не удалось записать параметры сервера");
return;
}
res.send();
}