Files
StopShopping/StopShopping.FileApi/Routes.cs
2026-03-30 11:07:30 +08:00

32 lines
840 B
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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<ApiResponse<FileUploadResp>> UploadAsync(
[FromForm] UploadParams payload,
IFileService fileService)
{
return await fileService.UploadFileAsync(payload);
}
}