I have ASP.Net Core Web API Controller's method that returns List<Car> based on query parameters.
[HttpPost("cars")]
public async Task<List<Car>> GetCars([FromBody] CarParams par)
{
//...
}
Parameters are grouped in record type CarParams. There are about 20 parameters:
public class CarParams
{
public string EngineType { get; set; }
public int WheelsCount { get; set; }
/// ... 20 params
public bool IsTruck { get; set; }
}
I need to change this method from POST to GET, because I want to use a server-side caching for such requests.
Should I create a controller's method with 20 params?
[HttpGet("cars")]
public async Task<List<Car>> GetCars(string engineType,
int wheelsCount,
/*...20 params?...*/
bool isTruck)
{
//...
}
If this is the case: Is there a way to automatically generate such a complex URL for a client-side app?