瀏覽代碼

#mvc路径bug

zxs 4 月之前
父節點
當前提交
90be9d860a
共有 1 個文件被更改,包括 7 次插入2 次删除
  1. 7 2
      robot/robotics/mvc.hpp

+ 7 - 2
robot/robotics/mvc.hpp

@@ -2158,7 +2158,12 @@ namespace robotics::v3 {
 			}
 			void fill_file(std::filesystem::path const& path, http::status status = http::status::ok) {
 				auto& response = http_context::current()->response;
-				response.fill_file(path, status);
+				if (path.c_str()[0] == '/' || path.c_str()[0] == '\\') {
+					response.fill_file(path, status);
+				}
+				else {
+					response.fill_file("/" + path.string(), status);
+				}
 			}
 			void fill_html(std::string const& html, http::status status = http::status::ok) {
 				auto& response = http_context::current()->response;
@@ -2198,7 +2203,7 @@ namespace robotics::v3 {
 				fill_file(get_filename(), status);
 			}
 			std::filesystem::path get_filename() {
-				return "/" + mvc::http_context::current()->get_controller_action()->file_mapping;
+				return mvc::http_context::current()->get_controller_action()->file_mapping;
 			}
 		};