This commit is contained in:
parent
aaaeb4429f
commit
105db1cbab
@ -16,6 +16,9 @@
|
||||
插入 url,visitor_uuid,last_user_agent ,last_view_time至表中,如果表中已存在url,visitor_uuid的item,则更新last_user_agent ,last_view_time,并将page_view_count加1,否则创建新的item,并将page_view_count赋值为1
|
||||
|
||||
|
||||
## Live2D 模型添加
|
||||
模型相关文件放置在 DocumentRoot/resources/live2d下。
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -267,10 +267,18 @@ Application::Application(const std::string &path)
|
||||
});
|
||||
m_router->insert("/api/v1/search/reindex", [this](HttpSession &session, const Request &request, const boost::urls::matches &matches) {
|
||||
using namespace boost::beast;
|
||||
std::string authorizationHeader;
|
||||
if (request.count(http::field::authorization)) {
|
||||
authorizationHeader = request[http::field::authorization];
|
||||
}
|
||||
http::response<boost::beast::http::string_body> s{http::status::ok, request.version()};
|
||||
if (!authorizationHeader.empty() && authorizationHeader.substr(0, 7) == "Bearer ") {
|
||||
std::string bearerToken = authorizationHeader.substr(7);
|
||||
auto key = getMeiliSearchApiKey();
|
||||
auto config = getMeiliSearchConfig();
|
||||
boost::json::object reply;
|
||||
if (!key.empty() && !config.empty()) {
|
||||
if (key == bearerToken) {
|
||||
config = std::filesystem::absolute(config);
|
||||
LOG(info) << "config path: " << config;
|
||||
boost::process::process process(session.executor(), "/usr/bin/docker", {"run", "-t", "--rm", "--network=host",
|
||||
@ -284,15 +292,24 @@ Application::Application(const std::string &path)
|
||||
int code = process.wait(error);
|
||||
reply["status"] = code;
|
||||
reply["message"] = error ? error.message() : "succeed.";
|
||||
} else {
|
||||
s.result(http::status::unauthorized);
|
||||
reply["status"] = static_cast<int>(http::status::unauthorized);
|
||||
reply["message"] = "Unauthorized";
|
||||
}
|
||||
} else {
|
||||
reply["status"] = 404;
|
||||
reply["message"] = "please fill MeiliSearchApiKey and MeiliSearchConfig.";
|
||||
}
|
||||
http::response<boost::beast::http::string_body> s{boost::beast::http::status::ok, request.version()};
|
||||
s.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||
s.set(http::field::content_type, "application/json;charset=UTF-8");
|
||||
s.keep_alive(request.keep_alive());
|
||||
s.body() = boost::json::serialize(reply);
|
||||
} else {
|
||||
s.result(http::status::unauthorized);
|
||||
s.set(http::field::content_type, "text/plain");
|
||||
s.body() = "Unauthorized";
|
||||
}
|
||||
s.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||
s.keep_alive(request.keep_alive());
|
||||
s.prepare_payload();
|
||||
session.reply(std::move(s));
|
||||
});
|
||||
|
@ -20,6 +20,10 @@ location /日常随笔 {
|
||||
access_by_lua_file lua/authentication.lua;
|
||||
}
|
||||
|
||||
location = /api/v1/search/reindex {
|
||||
proxy_pass http://local;
|
||||
}
|
||||
|
||||
location ^~ /api/v1/search/ {
|
||||
proxy_pass http://meilisearch/;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user