| 5 | namespace QuestionService.Controllers; |
| 6 | |
| 7 | [ApiController] |
| 8 | [Route("[controller]")] |
| 9 | public class TestController : ControllerBase |
| 10 | { |
| 11 | [HttpGet("errors")] |
| 12 | public ActionResult GetErrorResponses(int code) |
| 13 | { |
| 14 | ModelState.AddModelError("Problem one", "Validation problem one"); |
| 15 | ModelState.AddModelError("Problem two", "Validation problem two"); |
| 16 | |
| 17 | return code switch |
| 18 | { |
| 19 | 400 => BadRequest("Opposite of good request"), |
| 20 | 401 => Unauthorized(), |
| 21 | 403 => Forbid(), |
| 22 | 404 => NotFound(), |
| 23 | 500 => throw new Exception("This is a server error"), |
| 24 | _ => ValidationProblem(ModelState) |
| 25 | }; |
| 26 | } |
| 27 | |
| 28 | [Authorize] |
| 29 | [HttpGet("auth")] |
| 30 | public ActionResult TestAuth() |
| 31 | { |
| 32 | var user = User.FindFirstValue("name"); |
| 33 | |
| 34 | return Ok($"{user} has been authorized"); |
| 35 | } |
| 36 | } |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…