Skip to content

Commit

Permalink
Create TeapotController
Browse files Browse the repository at this point in the history
  • Loading branch information
RieBi committed Jul 26, 2024
1 parent 8e7e0b0 commit a0dc178
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
35 changes: 35 additions & 0 deletions Api/Controllers/TeaController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using Application.Exceptions;
using Microsoft.AspNetCore.Mvc;

namespace Api.Controllers;
[Route("api/[controller]")]
[ApiController]
public class TeaController : ControllerBase
{
[HttpGet]
[Route("GetTea")]
[ProducesResponseType<string>(200)]
public string GetTea() => teaArt;

[HttpGet]
[Route("GetCoffee")]
[ProducesResponseType<ErrorDto>(418)]
public ActionResult GetCoffee()
{
var error = new ErrorDto(new PermanentlyTeapotException(), "I'm a teapot, not a coffemaker, permanently now.");
return new ObjectResult(error)
{
StatusCode = 418
};
}

private static readonly string teaArt = """
;,'
_o_ ;:;'
,-.'---`.__ ;
((j`=====',-'
`-\ /
`-=-'
""";
}
2 changes: 2 additions & 0 deletions Application/Exceptions/IAmTeapotException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
namespace Application.Exceptions;
public class PermanentlyTeapotException : BrewABeerException;

0 comments on commit a0dc178

Please sign in to comment.