MCPcopy Create free account
hub / github.com/TryCatchLearn/Overflow / TestController

Class TestController

QuestionService/Controllers/TestController.cs:7–36  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5namespace QuestionService.Controllers;
6
7[ApiController]
8[Route("[controller]")]
9public 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}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…