Default project
This commit is contained in:
parent
23037521d4
commit
f8ac86e31b
@ -0,0 +1,16 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<UserSecretsId>12ea8899-f963-4978-9139-09d18ab72fdc</UserSecretsId>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -0,0 +1,6 @@
|
||||
@AwesomeMicroservices.WebApi_HostAddress = http://localhost:5007
|
||||
|
||||
GET {{AwesomeMicroservices.WebApi_HostAddress}}/weatherforecast/
|
||||
Accept: application/json
|
||||
|
||||
###
|
@ -0,0 +1,33 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace AwesomeMicroservices.WebApi.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class WeatherForecastController : ControllerBase
|
||||
{
|
||||
private static readonly string[] Summaries = new[]
|
||||
{
|
||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||
};
|
||||
|
||||
private readonly ILogger<WeatherForecastController> _logger;
|
||||
|
||||
public WeatherForecastController(ILogger<WeatherForecastController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
[HttpGet(Name = "GetWeatherForecast")]
|
||||
public IEnumerable<WeatherForecast> Get()
|
||||
{
|
||||
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
||||
{
|
||||
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
|
||||
TemperatureC = Random.Shared.Next(-20, 55),
|
||||
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
|
||||
})
|
||||
.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
30
AwesomeMicroservices.WebApi/Dockerfile
Normal file
30
AwesomeMicroservices.WebApi/Dockerfile
Normal file
@ -0,0 +1,30 @@
|
||||
# See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
|
||||
|
||||
# This stage is used when running from VS in fast mode (Default for Debug configuration)
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
|
||||
USER $APP_UID
|
||||
WORKDIR /app
|
||||
EXPOSE 8080
|
||||
EXPOSE 8081
|
||||
|
||||
|
||||
# This stage is used to build the service project
|
||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
WORKDIR /src
|
||||
COPY ["AwesomeMicroservices.WebApi/AwesomeMicroservices.WebApi.csproj", "AwesomeMicroservices.WebApi/"]
|
||||
RUN dotnet restore "./AwesomeMicroservices.WebApi/AwesomeMicroservices.WebApi.csproj"
|
||||
COPY . .
|
||||
WORKDIR "/src/AwesomeMicroservices.WebApi"
|
||||
RUN dotnet build "./AwesomeMicroservices.WebApi.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
||||
|
||||
# This stage is used to publish the service project to be copied to the final stage
|
||||
FROM build AS publish
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
RUN dotnet publish "./AwesomeMicroservices.WebApi.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
||||
|
||||
# This stage is used in production or when running from VS in regular mode (Default when not using the Debug configuration)
|
||||
FROM base AS final
|
||||
WORKDIR /app
|
||||
COPY --from=publish /app/publish .
|
||||
ENTRYPOINT ["dotnet", "AwesomeMicroservices.WebApi.dll"]
|
36
AwesomeMicroservices.WebApi/Program.cs
Normal file
36
AwesomeMicroservices.WebApi/Program.cs
Normal file
@ -0,0 +1,36 @@
|
||||
|
||||
namespace AwesomeMicroservices.WebApi
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
|
||||
builder.Services.AddControllers();
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
||||
}
|
||||
}
|
||||
}
|
52
AwesomeMicroservices.WebApi/Properties/launchSettings.json
Normal file
52
AwesomeMicroservices.WebApi/Properties/launchSettings.json
Normal file
@ -0,0 +1,52 @@
|
||||
{
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"dotnetRunMessages": true,
|
||||
"applicationUrl": "http://localhost:5007"
|
||||
},
|
||||
"https": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"dotnetRunMessages": true,
|
||||
"applicationUrl": "https://localhost:7135;http://localhost:5007"
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"Container (Dockerfile)": {
|
||||
"commandName": "Docker",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_HTTPS_PORTS": "8081",
|
||||
"ASPNETCORE_HTTP_PORTS": "8080"
|
||||
},
|
||||
"publishAllPorts": true,
|
||||
"useSSL": true
|
||||
}
|
||||
},
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:49517",
|
||||
"sslPort": 44336
|
||||
}
|
||||
}
|
||||
}
|
13
AwesomeMicroservices.WebApi/WeatherForecast.cs
Normal file
13
AwesomeMicroservices.WebApi/WeatherForecast.cs
Normal file
@ -0,0 +1,13 @@
|
||||
namespace AwesomeMicroservices.WebApi
|
||||
{
|
||||
public class WeatherForecast
|
||||
{
|
||||
public DateOnly Date { get; set; }
|
||||
|
||||
public int TemperatureC { get; set; }
|
||||
|
||||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
||||
|
||||
public string? Summary { get; set; }
|
||||
}
|
||||
}
|
8
AwesomeMicroservices.WebApi/appsettings.Development.json
Normal file
8
AwesomeMicroservices.WebApi/appsettings.Development.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
9
AwesomeMicroservices.WebApi/appsettings.json
Normal file
9
AwesomeMicroservices.WebApi/appsettings.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
@ -20,10 +20,4 @@
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\awesomemicroservices.client\awesomemicroservices.client.esproj">
|
||||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
15832
AwesomeMicroservices/awesomemicroservices.client/package-lock.json
generated
Normal file
15832
AwesomeMicroservices/awesomemicroservices.client/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,11 +1,9 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.12.35527.113 d17.12
|
||||
VisualStudioVersion = 17.12.35527.113
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AwesomeMicroservices.Server", "AwesomeMicroservices\AwesomeMicroservices.Server\AwesomeMicroservices.Server.csproj", "{758C914B-C1D9-46E2-95F6-CDE1E282E283}"
|
||||
EndProject
|
||||
Project("{54A90642-561A-4BB1-A94E-469ADEE60C69}") = "awesomemicroservices.client", "AwesomeMicroservices\awesomemicroservices.client\awesomemicroservices.client.esproj", "{32A7249B-E416-4273-85AB-E8411FE0C8CA}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AwesomeMicroservices.WebApi", "AwesomeMicroservices.WebApi\AwesomeMicroservices.WebApi.csproj", "{B0EDD9B6-A3D1-4DCC-B9B3-7000997551BA}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -13,16 +11,10 @@ Global
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{758C914B-C1D9-46E2-95F6-CDE1E282E283}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{758C914B-C1D9-46E2-95F6-CDE1E282E283}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{758C914B-C1D9-46E2-95F6-CDE1E282E283}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{758C914B-C1D9-46E2-95F6-CDE1E282E283}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{32A7249B-E416-4273-85AB-E8411FE0C8CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{32A7249B-E416-4273-85AB-E8411FE0C8CA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{32A7249B-E416-4273-85AB-E8411FE0C8CA}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
|
||||
{32A7249B-E416-4273-85AB-E8411FE0C8CA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{32A7249B-E416-4273-85AB-E8411FE0C8CA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{32A7249B-E416-4273-85AB-E8411FE0C8CA}.Release|Any CPU.Deploy.0 = Release|Any CPU
|
||||
{B0EDD9B6-A3D1-4DCC-B9B3-7000997551BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B0EDD9B6-A3D1-4DCC-B9B3-7000997551BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B0EDD9B6-A3D1-4DCC-B9B3-7000997551BA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B0EDD9B6-A3D1-4DCC-B9B3-7000997551BA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
Loading…
x
Reference in New Issue
Block a user