From a0dc17843ca3f045ffe63567ca996f42ebe657ec Mon Sep 17 00:00:00 2001 From: RieBi <42877671+RieBi@users.noreply.github.com> Date: Fri, 26 Jul 2024 11:54:26 +0200 Subject: [PATCH] Create TeapotController --- Api/Controllers/TeaController.cs | 35 ++++++++++++++++++++ Application/Exceptions/IAmTeapotException.cs | 2 ++ 2 files changed, 37 insertions(+) create mode 100644 Api/Controllers/TeaController.cs create mode 100644 Application/Exceptions/IAmTeapotException.cs diff --git a/Api/Controllers/TeaController.cs b/Api/Controllers/TeaController.cs new file mode 100644 index 0000000..0960804 --- /dev/null +++ b/Api/Controllers/TeaController.cs @@ -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(200)] + public string GetTea() => teaArt; + + [HttpGet] + [Route("GetCoffee")] + [ProducesResponseType(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`=====',-' + `-\ / + `-=-' + + """; +} diff --git a/Application/Exceptions/IAmTeapotException.cs b/Application/Exceptions/IAmTeapotException.cs new file mode 100644 index 0000000..b24147a --- /dev/null +++ b/Application/Exceptions/IAmTeapotException.cs @@ -0,0 +1,2 @@ +namespace Application.Exceptions; +public class PermanentlyTeapotException : BrewABeerException;