I have this API as you can see:
app.MapGet("/api/fund/{fundCode}", ([FromServices] IMediator mediator,string fundCode)
=> mediator.Send(new GetFundsQuery(fundCode)));
I want to set fundcode
as an optional parameter to my API, so I changed it to
app.MapGet("/api/fund/{fundCode?}", ([FromServices] IMediator mediator,string fundCode)
=> mediator.Send(new GetFundsQuery(fundCode)));
But it didn't work, and when I call this address
https://localhost:7147/api/fund
I get an http 404 error. Why?