From 9b37c18fcc12d39f4942efaeb97cd4c8446ee729 Mon Sep 17 00:00:00 2001 From: xx Date: Fri, 14 Jun 2024 16:01:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DLUA=E6=89=BE=E4=B8=8D?= =?UTF-8?q?=E5=88=B0=E8=84=9A=E6=9C=AC=E6=96=87=E4=BB=B6=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/subscribemanager.cpp | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/src/core/subscribemanager.cpp b/src/core/subscribemanager.cpp index 2249f98..96a3e97 100644 --- a/src/core/subscribemanager.cpp +++ b/src/core/subscribemanager.cpp @@ -127,27 +127,20 @@ void fastweb::subscribe_manager::other(network::http::request* request, network: } } + // 文件全路径 + std::string absolute_path = app()->config->website.dir + filepath; + // 扩展名 std::string ext = ylib::file::ext(filepath); - // 判断LUA - if (ext == "lua") + if (ylib::file::exist(absolute_path) == false) { - if (app()->config->website.direct_url_mapping) - { - callback(request,response,filepath,filepath); - } - else - { - send_404(response); - } + send_404(response); + } + else if(ext == "lua" && app()->config->website.direct_url_mapping) + { + callback(request, response, filepath, filepath); return; } - - // 发送静态文件 - std::string absolute_path = app()->config->website.dir + filepath; - if (ylib::file::exist(absolute_path)) - response->send_file(absolute_path); - else - send_404(response); + response->send_file(absolute_path); } void fastweb::subscribe_manager::send_404(network::http::response* response)