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.

56 lines
1.6 KiB

using System;
using System.Collections.Generic;
namespace Apewer.Web
{
/// <summary></summary>
public abstract class ApiController : IDisposable
{
internal ApiApplication Application = null;
internal ApiFunction Function = null;
private ApiRequest _request = null;
private ApiResponse _response = null;
private bool _allow = true;
/// <summary>获取 API 请求模型。</summary>
public virtual ApiRequest Request
{
get { return _request; }
internal set { _request = value; }
}
/// <summary>获取 API 响应模型。</summary>
public virtual ApiResponse Response
{
get
{
if (_response == null) _response = new ApiResponse();
return _response;
}
internal set { _response = value; }
}
/// <summary>获取或设置初始化方法。</summary>
public virtual Action AfterInitialized { get; set; }
/// <summary>获取或设置默认功能,在匹配 Function 失败后调用。</summary>
public virtual Action DefaultFunction { get; set; }
/// <summary>默认允许调用 Function。当存在 Independent 特性时 Invoker 将忽略此值,且不调用 Function。</summary>
public virtual bool AllowFunction
{
get { return _allow; }
protected set { _allow = value; }
}
/// <summary></summary>
public virtual void Dispose() { }
void InvalidFunction() => Response.Error("指定的 Function 无效。");
}
}