You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
3.7 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Web;
  4. namespace Apewer.Web
  5. {
  6. /// <summary>选项。</summary>
  7. public static class ApiOptions
  8. {
  9. /// <summary>允许 Invoker 解析 favicon.ico 请求。</summary>
  10. /// <remarks>默认值:不允许,响应空。</remarks>
  11. public static bool AllowFavIcon { get; set; } = false;
  12. /// <summary>允许 Invoker 解析 robots.txt 请求。</summary>
  13. /// <remarks>默认值:不允许,拒绝搜索引擎收录根目录。</remarks>
  14. public static bool AllowRobots { get; set; } = false;
  15. /// <summary>允许 Invoker 枚举输出 Applications 或 Functions。</summary>
  16. /// <remarks>默认值:不允许,不输出列表。</remarks>
  17. public static bool AllowEnumerate { get; set; } = false;
  18. /// <summary>允许 Invoker 输出 Exception 对象的属性。</summary>
  19. /// <remarks>默认值:不允许输出。</remarks>
  20. public static bool AllowException { get; set; } = false;
  21. /// <summary>允许 Invoker 输出的 Json 对象缩进。</summary>
  22. /// <remarks>默认值:不缩进。</remarks>
  23. public static bool JsonIndent { get; set; } = false;
  24. /// <summary>允许 Invoker 输出 Application 列表时包含模块名称。</summary>
  25. /// <remarks>默认值:不包含。</remarks>
  26. public static bool WithModuleName { get; set; } = false;
  27. /// <summary>允许 Invoker 输出 Application 列表时包含类型名称。</summary>
  28. /// <remarks>默认值:不包含。</remarks>
  29. public static bool WithTypeName { get; set; } = false;
  30. /// <summary>在响应中包含时间属性。</summary>
  31. /// <remarks>默认值:不包含。</remarks>
  32. public static bool WithClock { get; set; } = false;
  33. /// <summary>在响应中包含执行 API 的持续时间。</summary>
  34. /// <remarks>默认值:包含。</remarks>
  35. public static bool WithDuration { get; set; } = true;
  36. /// <summary>在响应中包含 Application 和 Function 属性。</summary>
  37. /// <remarks>默认值:不包含。</remarks>
  38. public static bool WithTarget { get; set; } = false;
  39. /// <summary>在响应中包含 Access-Control 属性。</summary>
  40. /// <remarks>默认值:包含。</remarks>
  41. public static bool WithAccessControl { get; set; } = true;
  42. /// <summary>设置 Access-Control-Max-Age 的值。</summary>
  43. /// <remarks>默认值:60。</remarks>
  44. public static int AccessControlMaxAge { get; set; } = 60;
  45. /// <summary>移除 Response 中的 Server 属性。</summary>
  46. /// <remarks>默认值:不移除。</remarks>
  47. public static bool RemoveResponseServer { get; set; } = false;
  48. /// <summary>允许同步 IO。</summary>
  49. /// <remarks>
  50. /// <para>默认值:允许。</para>
  51. /// <para>允许:使用同步方法写入 Response.Body,可能会导致线程不足而崩溃。</para>
  52. /// <para>不允许:必须用异步方法写入 Response.Body。</para>
  53. /// </remarks>
  54. internal static bool AllowSynchronousIO { get; set; } = true;
  55. #region Static Web
  56. private static Type _default = null;
  57. /// <summary>获取默认控制器类型。</summary>
  58. public static Type Default { get { return _default; } }
  59. /// <summary>设置默认控制器类型。</summary>
  60. public static void SetDefault<T>() where T : ApiController => _default = typeof(T);
  61. /// <summary>取消默认控制器类型。</summary>
  62. public static void CancelDefault() => _default = null;
  63. #endregion
  64. }
  65. }