using System; using System.Collections.Generic; using System.Web; namespace Apewer.Web { /// 选项。 public static class ApiOptions { /// 允许 Invoker 解析 favicon.ico 请求。 /// 默认值:不允许,响应空。 public static bool AllowFavIcon { get; set; } = false; /// 允许 Invoker 解析 robots.txt 请求。 /// 默认值:不允许,拒绝搜索引擎收录根目录。 public static bool AllowRobots { get; set; } = false; /// 允许 Invoker 枚举输出 Applications 或 Functions。 /// 默认值:不允许,不输出列表。 public static bool AllowEnumerate { get; set; } = false; /// 允许 Invoker 输出 Exception 对象的属性。 /// 默认值:不允许输出。 public static bool AllowException { get; set; } = false; /// 允许 Invoker 输出的 Json 对象缩进。 /// 默认值:不缩进。 public static bool JsonIndent { get; set; } = false; /// 允许 Invoker 输出 Application 列表时包含模块名称。 /// 默认值:不包含。 public static bool WithModuleName { get; set; } = false; /// 允许 Invoker 输出 Application 列表时包含类型名称。 /// 默认值:不包含。 public static bool WithTypeName { get; set; } = false; /// 在响应中包含时间属性。 /// 默认值:不包含。 public static bool WithClock { get; set; } = false; /// 在响应中包含执行 API 的持续时间。 /// 默认值:包含。 public static bool WithDuration { get; set; } = true; /// 在响应中包含 Application 和 Function 属性。 /// 默认值:不包含。 public static bool WithTarget { get; set; } = false; /// 在响应中包含 Access-Control 属性。 /// 默认值:包含。 public static bool WithAccessControl { get; set; } = true; /// 设置 Access-Control-Max-Age 的值。 /// 默认值:60。 public static int AccessControlMaxAge { get; set; } = 60; /// 移除 Response 中的 Server 属性。 /// 默认值:不移除。 public static bool RemoveResponseServer { get; set; } = false; /// 允许同步 IO。 /// /// 默认值:允许。 /// 允许:使用同步方法写入 Response.Body,可能会导致线程不足而崩溃。 /// 不允许:必须用异步方法写入 Response.Body。 /// internal static bool AllowSynchronousIO { get; set; } = true; #region Static Web private static Type _default = null; /// 获取默认控制器类型。 public static Type Default { get { return _default; } } /// 设置默认控制器类型。 public static void SetDefault() where T : ApiController => _default = typeof(T); /// 取消默认控制器类型。 public static void CancelDefault() => _default = null; #endregion } }