MinimalAPI---传递参数

Posted on 2022-07-30 10:19  樱木007  阅读(149)  评论(0编辑  收藏  举报
using Microsoft.AspNetCore.Mvc;
using MininalApi.Demo1;

WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
WebApplication app = builder.Build();
app.UseSwagger();
app.UseSwaggerUI();

#region 传递参数
app.MapGet("api/ParaInt",(int i)=>i);
app.MapGet("api/ParaString",(string j) => { return j; });
app.MapGet("api/ParaIntString", (int i,string j) => i.ToString()+j);
app.MapGet("api/ParaModel",([FromBody] Commodity commodity)=>commodity);
app.MapGet("api/ParaList", ([FromBody] List<Commodity> list) => list);
#endregion


app.Run();

 

Copyright © 2024 樱木007
Powered by .NET 9.0 on Kubernetes