diff --git a/WD7UVN_HFT_2023241.Endpoint/Program.cs b/WD7UVN_HFT_2023241.Endpoint/Program.cs index 73af018..c99126c 100644 --- a/WD7UVN_HFT_2023241.Endpoint/Program.cs +++ b/WD7UVN_HFT_2023241.Endpoint/Program.cs @@ -1,6 +1,11 @@ using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; namespace WD7UVN_HFT_2023241.Endpoint { diff --git a/WD7UVN_HFT_2023241.Endpoint/Properties/launchSettings.json b/WD7UVN_HFT_2023241.Endpoint/Properties/launchSettings.json index 034a3a5..151a548 100644 --- a/WD7UVN_HFT_2023241.Endpoint/Properties/launchSettings.json +++ b/WD7UVN_HFT_2023241.Endpoint/Properties/launchSettings.json @@ -1,16 +1,18 @@ { + "$schema": "http://json.schemastore.org/launchsettings.json", "iisSettings": { "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:42469", - "sslPort": 44362 + "applicationUrl": "http://localhost:31272", + "sslPort": 44388 } }, "profiles": { "IIS Express": { "commandName": "IISExpress", "launchBrowser": true, + "launchUrl": "swagger", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } @@ -19,6 +21,7 @@ "commandName": "Project", "dotnetRunMessages": "true", "launchBrowser": true, + "launchUrl": "swagger", "applicationUrl": "https://localhost:5001;http://localhost:5000", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" diff --git a/WD7UVN_HFT_2023241.Endpoint/Startup.cs b/WD7UVN_HFT_2023241.Endpoint/Startup.cs index 51e5232..7d5f4c6 100644 --- a/WD7UVN_HFT_2023241.Endpoint/Startup.cs +++ b/WD7UVN_HFT_2023241.Endpoint/Startup.cs @@ -1,8 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.HttpsPolicy; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using Microsoft.OpenApi.Models; +using WD7UVN_HFT_2023241.Models; using WD7UVN_HFT_2023241.Logic; using WD7UVN_HFT_2023241.Repository; @@ -10,13 +19,25 @@ namespace WD7UVN_HFT_2023241.Endpoint { public class Startup { + public Startup(IConfiguration configuration) + { + Configuration = configuration; + } + + public IConfiguration Configuration { get; } + // This method gets called by the runtime. Use this method to add services to the container. - // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { services.AddTransient(); - services.AddTransient(); - services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + + services.AddControllers(); + services.AddSwaggerGen(c => + { + c.SwaggerDoc("v1", new OpenApiInfo { Title = "WD7UVN_HFT_2023241.Endpoint", Version = "v1" }); + }); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. @@ -25,16 +46,19 @@ namespace WD7UVN_HFT_2023241.Endpoint if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); + app.UseSwagger(); + app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "WD7UVN_HFT_2023241.Endpoint v1")); } + app.UseHttpsRedirection(); + app.UseRouting(); + app.UseAuthorization(); + app.UseEndpoints(endpoints => { - endpoints.MapGet("/", async context => - { - await context.Response.WriteAsync("Hello World!"); - }); + endpoints.MapControllers(); }); } } diff --git a/WD7UVN_HFT_2023241.Endpoint/WD7UVN_HFT_2023241.Endpoint.csproj b/WD7UVN_HFT_2023241.Endpoint/WD7UVN_HFT_2023241.Endpoint.csproj index ed96602..9023e9d 100644 --- a/WD7UVN_HFT_2023241.Endpoint/WD7UVN_HFT_2023241.Endpoint.csproj +++ b/WD7UVN_HFT_2023241.Endpoint/WD7UVN_HFT_2023241.Endpoint.csproj @@ -5,9 +5,13 @@ - - - + + + + + + + diff --git a/WD7UVN_HFT_2023241.Endpoint/WD7UVN_HFT_2023241.Endpoint.http b/WD7UVN_HFT_2023241.Endpoint/WD7UVN_HFT_2023241.Endpoint.http new file mode 100644 index 0000000..9633ec6 --- /dev/null +++ b/WD7UVN_HFT_2023241.Endpoint/WD7UVN_HFT_2023241.Endpoint.http @@ -0,0 +1,6 @@ +@WD7UVN_HFT_2023241.Endpoint_HostAddress = http://localhost:5146 + +GET {{WD7UVN_HFT_2023241.Endpoint_HostAddress}}/weatherforecast/ +Accept: application/json + +###