Core下简易WebApi
2024-09-07 18:32:59
代码很粗糙~
粘贴github地址
https://github.com/htrlq/MiniAspNetCoreMini
demo
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
} public IConfiguration Configuration { get; } // This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc(); services
.AddApiServerInit()
.AddApiServer<MyController>();
} // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
} app.UseMvc(); app.UseRouter(route =>
{
route.UserApiServer();
});
}
} public enum OrderSort
{
DoExecute,
Success,
NotPay
} public class ParamOrderSort
{
[Required]
public Guid? UserId { get; set; }
[Required]
public OrderSort? Type { get; set; }
public int? PageIndex { get; set; }
public int? PageSize { get; set; }
} public class MyController : ApiServerBase
{
[HttpGet]
[HttpPost]
public async Task Show(ParamOrderSort param)
{
await context.HttpContext.Response.WriteAsync($"{param.UserId} {param.Type} {param.PageIndex} {param.PageSize}");
} public MyController(IHttpContextAccessor context) : base(context)
{
}
}
最新文章
- HDU 1281 二分图
- 字符串匹配的KMP算法
- php课程---面向对象
- Silverlight ModelView中调用UI进程
- Maven错误在这里看【项目无法成功编译由于maven未成功下载依赖导致】
- 1154 能量项链[区间dp]
- java反射知识
- UITableView的简单应用介绍
- Oracle start with connect by prior 用法
- Git 版本回退问题详解
- swift 定位 根据定位到的经纬度转换城市名
- ios开发 第一天
- 自己动手写Redis客户端(C#实现)2 - SET请求和状态回复(set)
- XML数据读取——Digester简单使用
- zc702-自定义AXI-IP核实验
- git 远程删除文件
- 如何在 sublime text 中以当前文件目录打开 cmd
- 『转』credential Provider 简易改写攻略
- 启动服务报错:nested exception is java.lang.NoSuchMethodError: org.apache.cxf.common.jaxb.JAXBUtils.closeUnmarshaller(Ljavax/xml/bind/Unmarshaller;)V
- BFS和DFS (java版)