webuiconf.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. //
  2. // Created by xcbosa on 2023/1/28.
  3. //
  4. #pragma once
  5. #include <vector>
  6. #include <map>
  7. #include "utils/utils.h"
  8. using namespace std;
  9. using namespace xc::utils;
  10. namespace xc::conf {
  11. const int clientSocketTimeoutSeconds = 3;
  12. const int taskProcessTimeoutSeconds = 1;
  13. const int mtu = 1536;
  14. const map<string, string> fileExtensionToMimeTypes = {
  15. { ".html", "text/html" },
  16. { ".htm", "text/html" },
  17. { ".js", "text/javascript" },
  18. { ".xcnb", "text/xc-notebook" },
  19. { ".ccdproj", "application/c-code-develop-project" },
  20. { ".png", "image/png" },
  21. { ".jpg", "image/jpeg" },
  22. { ".jpeg", "image/jpeg" },
  23. { ".tiff", "image/tiff" },
  24. { "default", "application/octet-stream" },
  25. };
  26. const IncompleteFileResponseData errorPage(FileResponseData(500, "html/error.html", "text/html"));
  27. const auto errorPage400 = errorPage.applyReplacements(400, {
  28. Replacement("errorMessage", "请求格式错误,无法解析请求"),
  29. Replacement("errorCode", "400")
  30. });
  31. const auto errorPage404 = errorPage.applyReplacements(404, {
  32. Replacement("errorMessage", "不存在指定的资源"),
  33. Replacement("errorCode", "404")
  34. });
  35. const auto errorPage500 = errorPage.applyReplacements(500, {
  36. Replacement("errorMessage", "服务器内部错误,可能是服务器访问量过大,请稍后重试"),
  37. Replacement("errorCode", "500")
  38. });
  39. const auto errorPageTimeout = errorPage.applyReplacements(550, {
  40. Replacement("errorMessage", "服务器任务处理已超时,可能服务器访问量过大,请稍后重试"),
  41. Replacement("errorCode", "550")
  42. });
  43. }