I have the following controller method which accepts command as a change model passed from the client.
[HttpPut]
[Route("api/features/{name}")]
public async Task<IActionResult> PutFeatureValueAsync(
string name,
[FromBody] SetFeatureCommand command,
CancellationToken token)
{
command.FeatureName = name;
await mediator.Send(command, token).ConfigureAwait(false);
return Ok();
}
The problem is that I have to copy a FeatureName property to the command object manually if I want to keep the {name} in the url. The other problem is that I can't properly do a validation if the FeatureName is not set during model binding.
What would be the best way to have {name} segment of the path to automatically model bind to FeatureName property of the command.