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
|
插入 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下。
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -264,35 +264,52 @@ Application::Application(const std::string &path)
|
|||||||
s.body() = boost::json::serialize(reply);
|
s.body() = boost::json::serialize(reply);
|
||||||
s.prepare_payload();
|
s.prepare_payload();
|
||||||
session.reply(std::move(s));
|
session.reply(std::move(s));
|
||||||
});
|
});
|
||||||
m_router->insert("/api/v1/search/reindex", [this](HttpSession &session, const Request &request, const boost::urls::matches &matches) {
|
m_router->insert("/api/v1/search/reindex", [this](HttpSession &session, const Request &request, const boost::urls::matches &matches) {
|
||||||
using namespace boost::beast;
|
using namespace boost::beast;
|
||||||
auto key = getMeiliSearchApiKey();
|
std::string authorizationHeader;
|
||||||
auto config = getMeiliSearchConfig();
|
if (request.count(http::field::authorization)) {
|
||||||
boost::json::object reply;
|
authorizationHeader = request[http::field::authorization];
|
||||||
if (!key.empty() && !config.empty()) {
|
}
|
||||||
config = std::filesystem::absolute(config);
|
http::response<boost::beast::http::string_body> s{http::status::ok, request.version()};
|
||||||
LOG(info) << "config path: " << config;
|
if (!authorizationHeader.empty() && authorizationHeader.substr(0, 7) == "Bearer ") {
|
||||||
boost::process::process process(session.executor(), "/usr/bin/docker", {"run", "-t", "--rm", "--network=host",
|
std::string bearerToken = authorizationHeader.substr(7);
|
||||||
"--env=MEILISEARCH_HOST_URL=http://localhost:7700",
|
auto key = getMeiliSearchApiKey();
|
||||||
std::format("--env=MEILISEARCH_API_KEY={}", key),
|
auto config = getMeiliSearchConfig();
|
||||||
std::format("--volume={}:/docs-scraper/config.json", config),
|
boost::json::object reply;
|
||||||
"getmeili/docs-scraper:latest",
|
if (!key.empty() && !config.empty()) {
|
||||||
"pipenv", "run", "./docs_scraper", "config.json"
|
if (key == bearerToken) {
|
||||||
});
|
config = std::filesystem::absolute(config);
|
||||||
boost::process::error_code error;
|
LOG(info) << "config path: " << config;
|
||||||
int code = process.wait(error);
|
boost::process::process process(session.executor(), "/usr/bin/docker", {"run", "-t", "--rm", "--network=host",
|
||||||
reply["status"] = code;
|
"--env=MEILISEARCH_HOST_URL=http://localhost:7700",
|
||||||
reply["message"] = error ? error.message() : "succeed.";
|
std::format("--env=MEILISEARCH_API_KEY={}", key),
|
||||||
} else {
|
std::format("--volume={}:/docs-scraper/config.json", config),
|
||||||
reply["status"] = 404;
|
"getmeili/docs-scraper:latest",
|
||||||
reply["message"] = "please fill MeiliSearchApiKey and MeiliSearchConfig.";
|
"pipenv", "run", "./docs_scraper", "config.json"
|
||||||
|
});
|
||||||
|
boost::process::error_code error;
|
||||||
|
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.";
|
||||||
|
}
|
||||||
|
s.set(http::field::content_type, "application/json;charset=UTF-8");
|
||||||
|
s.body() = boost::json::serialize(reply);
|
||||||
|
} else {
|
||||||
|
s.result(http::status::unauthorized);
|
||||||
|
s.set(http::field::content_type, "text/plain");
|
||||||
|
s.body() = "Unauthorized";
|
||||||
}
|
}
|
||||||
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::server, BOOST_BEAST_VERSION_STRING);
|
||||||
s.set(http::field::content_type, "application/json;charset=UTF-8");
|
|
||||||
s.keep_alive(request.keep_alive());
|
s.keep_alive(request.keep_alive());
|
||||||
s.body() = boost::json::serialize(reply);
|
|
||||||
s.prepare_payload();
|
s.prepare_payload();
|
||||||
session.reply(std::move(s));
|
session.reply(std::move(s));
|
||||||
});
|
});
|
||||||
|
@ -20,6 +20,10 @@ location /日常随笔 {
|
|||||||
access_by_lua_file lua/authentication.lua;
|
access_by_lua_file lua/authentication.lua;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
location = /api/v1/search/reindex {
|
||||||
|
proxy_pass http://local;
|
||||||
|
}
|
||||||
|
|
||||||
location ^~ /api/v1/search/ {
|
location ^~ /api/v1/search/ {
|
||||||
proxy_pass http://meilisearch/;
|
proxy_pass http://meilisearch/;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user