angular - AspnetBoilerpate REST URL
问题描述
在浏览了文档和 github 问题之后,我找不到创建 RESTful api 的方法。如果我们想使用 RESTful,它仅指使用标准的 webapi 实现。
是否有另一种方法(无需完成重写当前的 webapi 实现)来获取 api 的 RESTful 并同时让服务代理与它们一起工作?
解决方案
您可以使用 Aspnet Boilerplate 创建 Restful API。这是一个示例,向您展示如何做到这一点。
public class TestAppService : SwagResterAppServiceBase, ITestAppService
{
[Route("api/services/app/Test")]
[HttpPost]
public Task CreateTest(TestDetailsDto input)
{
throw new NotImplementedException();
}
[Route("api/services/app/Test")]
[HttpDelete]
public Task DeleteTest(EntityDto input)
{
throw new NotImplementedException();
}
[Route("api/services/app/Test")]
[HttpGet]
public Task GetTest(EntityDto input)
{
throw new NotImplementedException();
}
[Route("api/services/app/Test")]
[HttpPut]
public Task UpdateTest(TestDetailsDto input)
{
throw new NotImplementedException();
}
}
public interface ITestAppService: IApplicationService, ITransientDependency
{
Task CreateTest(TestDetailsDto input);
Task DeleteTest(EntityDto input);
Task GetTest(EntityDto input);
Task UpdateTest(TestDetailsDto input);
}
public class TestDetailsDto
{
}
然后运行refresh.bat
以重新生成服务代理。
推荐阅读
- javascript - 轴改变旋转轴三个js
- javascript - 对话流:followEventInput
- java - Dropwizard 相当于 Spring 的 @Async
- docker - docker login 中的“保存凭据时出错”
- javascript - 在 TFS 仪表板小部件上使用 VSS 控件
- azure - Azure 资源在部署时找不到依赖关系
- sharepoint - 将 $.Deferred() 与嵌套的 $.each 语句一起使用
- java - 在 KafkaBolt 中暴露 Kafka 发布异常
- python - 有没有办法在 pandas to_html 中传递元刷新?
- file - JavaFX 文件资源管理器自定义