From f50957985300c3bfc6ae5564d7eaa67e099ca8f2 Mon Sep 17 00:00:00 2001 From: transtrike Date: Thu, 10 Dec 2020 13:45:35 +0200 Subject: Change HTTP port --- API/Controllers/ErrorController.cs | 13 ++++++++++ API/Controllers/WeatherForecastController.cs | 37 ---------------------------- API/Program.cs | 16 ++++++------ API/Startup.cs | 4 +++ API/WeatherForecast.cs | 15 ----------- 5 files changed, 25 insertions(+), 60 deletions(-) create mode 100644 API/Controllers/ErrorController.cs delete mode 100644 API/Controllers/WeatherForecastController.cs delete mode 100644 API/WeatherForecast.cs (limited to 'API') diff --git a/API/Controllers/ErrorController.cs b/API/Controllers/ErrorController.cs new file mode 100644 index 0000000..4c5d9ef --- /dev/null +++ b/API/Controllers/ErrorController.cs @@ -0,0 +1,13 @@ +using System; + +namespace API.Controllers +{ + public class ErrorController + { + //FIXME: SHOULD NOT BE VOID + public void Error(Exception exception) + { + + } + } +} \ No newline at end of file diff --git a/API/Controllers/WeatherForecastController.cs b/API/Controllers/WeatherForecastController.cs deleted file mode 100644 index a90538d..0000000 --- a/API/Controllers/WeatherForecastController.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Logging; - -namespace API.Controllers -{ - [ApiController] - [Route("[controller]")] - public class WeatherForecastController : ControllerBase - { - private readonly ILogger _logger; - private static readonly string[] Summaries = new[] - { - "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" - }; - - public WeatherForecastController(ILogger logger) - { - _logger = logger; - } - - [HttpGet] - public IEnumerable Get() - { - var rng = new Random(); - return Enumerable.Range(1, 5).Select(index => new WeatherForecast - { - Date = DateTime.Now.AddDays(index), - TemperatureC = rng.Next(-20, 55), - Summary = Summaries[rng.Next(Summaries.Length)] - }) - .ToArray(); - } - } -} diff --git a/API/Program.cs b/API/Program.cs index 8125904..eedd5e1 100644 --- a/API/Program.cs +++ b/API/Program.cs @@ -4,13 +4,13 @@ using Microsoft.Extensions.Hosting; namespace API { public class Program - { - private const int HTTPS_PORT = 5020; + { + private const int HTTPS_PORT = 5000; public static void Main(string[] args) - { - CreateHostBuilder(args).Build().Run(); - } + { + CreateHostBuilder(args).Build().Run(); + } public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) @@ -18,7 +18,7 @@ namespace API { webBuilder.ConfigureKestrel(opt => opt.ListenLocalhost(HTTPS_PORT)); - webBuilder.UseStartup(); - }); - } + webBuilder.UseStartup(); + }); + } } diff --git a/API/Startup.cs b/API/Startup.cs index 61bcaff..6167993 100644 --- a/API/Startup.cs +++ b/API/Startup.cs @@ -56,6 +56,10 @@ namespace API app.UseSwagger(); app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "API v1")); } + else + { + app.UseExceptionHandler(); + } app.UseHttpsRedirection(); app.UseRouting(); diff --git a/API/WeatherForecast.cs b/API/WeatherForecast.cs deleted file mode 100644 index 746c136..0000000 --- a/API/WeatherForecast.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; - -namespace API -{ - public class WeatherForecast - { - public DateTime Date { get; set; } - - public int TemperatureC { get; set; } - - public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); - - public string Summary { get; set; } - } -} -- cgit v1.2.3