using Microsoft.AspNetCore.Mvc; using StopShopping.FileApi.Extensions; using StopShopping.FileApi.Services; namespace StopShopping.FileApi; public static class Routes { public static void MapRoutes(WebApplication app) { app.MapGroup("") .MapRoutes() .WithInternalOnly(); } public static RouteGroupBuilder MapRoutes(this RouteGroupBuilder routes) { routes.MapPost("/upload", UploadAsync) .DisableAntiforgery() .WithDescription("上传文件,对外接口自己实现anti-forgery(重要)"); return routes; } private static async Task> UploadAsync( [FromForm] UploadParams payload, IFileService fileService) { return await fileService.UploadFileAsync(payload); } }