I am configuring my server in various modes and I am setting the modes of the application from a config file. So, say if I run my HTTP server is in mode "X", I want clients to get "HTTP STATUS 200 and don't execute any logic" if they hit a valid endpoint. and if the server is in mode "Y" all endpoints should perform the logic and return the status as per the request processing
[Route("api/todo")]
public class TodoController : Controller{
//if in mode "Y"
[HttpGet("{id}", Name = "GetTodo")]
public IActionResult GetById(long id)
{
var item = _todoRepository.Find(id);
if (item == null)
{
return NotFound();
}
return new ObjectResult(item);
}
//if in mode "X"
[HttpGet("{id}", Name = "GetTodo")]
public IActionResult GetById(long id){
return Ok();
}
}
Is there a way using filter that can return OK to the client without getting inside of the action method?
EDIT: When i say modes, I mean like modes like "production", "testing", "staging". [like we have different db connection strings for all these modes] So, I have a mode called "X" [and if my server is running on mode "X"], any client who hits the endpoints exposed by me will get success.
