using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Serein.Proto.HttpApi { /// /// 表示参数为url中的数据 /// public class UrlAttribute : Attribute { } /// /// 表示入参参数为整个boby的数据 /// /// 例如:User类型含有int id、string name字段 /// /// ① Add(User user) /// 请求需要传入的json为 /// {"user":{ /// "id":2, /// "name":"李志忠"}} /// /// ② Add([Boby]User user) /// 请求需要传入的json为 /// {"id":2,"name":"李志忠"} /// /// public class BodyAttribute : Attribute { } /// /// 标记该类为 Web Api 处理类 /// public class WebApiControllerAttribute : Attribute { /// /// URL 路径 /// public string Url { get; } public WebApiControllerAttribute(string url = "") { Url = url; } } /// /// 方法的接口类型与附加URL /// [AttributeUsage(AttributeTargets.Method)] public class WebApiAttribute : Attribute { /// /// HTTP 请求类型 /// public ApiType ApiType; /// /// URL 路径 /// public string Url = string.Empty; public WebApiAttribute(ApiType http = ApiType.POST, string url = "") { ApiType = http; Url = url; } } public enum ApiType { POST, GET, //PUT, //DELETE } }