-
-
Notifications
You must be signed in to change notification settings - Fork 175
请求方式
Henry edited this page Sep 10, 2019
·
1 revision
组件提供以下几种请求类型的支持,分别是:GET
,POST
,PUT
和DELETE
.可以针对情况的需要给方法标记上相应的Attribute
,当方法没有标记的情况是GET
(注意:组件暂不支持一个方法支持多种请求).具体配置如下
[Post]
public object Employee(Employee item)
{
return new JsonResult(item);
}
public string GetTime(IHttpContext context)
{
return DateTime.Now.ToShortDateString();
}
[Put]
public User PutUser(User body)
{
body.Time = DateTime.Now;
return body;
}
[Del]
public object DelUser(string id)
{
return $"{DateTime.Now} {id}";
}
[Post(Route = "user/{id}")]
public User SetUser(string id, User body)
{
body.Time = DateTime.Now;
body.ID = id;
return body;
}