Parcourir la source

#mvc路径bug

zxs il y a 4 mois
Parent
commit
90be9d860a
1 fichiers modifiés avec 7 ajouts et 2 suppressions
  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;
 			}
 		};