Add project files.

This commit is contained in:
Dmitriy yawaflua Andreev
2024-07-08 02:05:16 +03:00
parent 1ebfdc052c
commit 5c940b4838
12 changed files with 262 additions and 0 deletions

30
.dockerignore Normal file
View File

@@ -0,0 +1,30 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
!**/.gitignore
!.git/HEAD
!.git/config
!.git/packed-refs
!.git/refs/heads/**

View File

@@ -0,0 +1,25 @@
using Microsoft.AspNetCore.Mvc;
using System.Xml.Linq;
namespace OembedTests.Controllers
{
[Route("/oembed")]
[ApiController]
public class OembedController : ControllerBase
{
[HttpGet]
public async Task<IActionResult> GetOembed([FromQuery]string url, [FromQuery] string? format = "json")
{
var userName = url.Replace("https://oembed-test.yawaflua.ru/pay/", "");
var response = $@"{{
""version"": ""1.0"",
""type"": ""link"",
""provider_name"": ""SP-Donate"",
""provider_url"": ""https://sp-donate.ru/"",
""title"": ""Donate to {userName} right now!"",
""thumbnail_url"": ""https://avatar.spworlds.ru/front/240/{userName}""
}}";
return Ok(response);
}
}
}

View File

@@ -0,0 +1,16 @@
using Microsoft.AspNetCore.Mvc;
namespace OembedTests.Controllers
{
[ApiController]
[Route("pay")]
public class WeatherForecastController : ControllerBase
{
[HttpGet("/{userName}")]
public async Task<IActionResult> Get(string userName)
{
return Ok(userName);
}
}
}

25
Dockerfile Normal file
View File

@@ -0,0 +1,25 @@
#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.
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER app
WORKDIR /app
EXPOSE 8080
EXPOSE 8081
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["OembedTests.csproj", "."]
RUN dotnet restore "./OembedTests.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "./OembedTests.csproj" -c $BUILD_CONFIGURATION -o /app/build
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./OembedTests.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "OembedTests.dll"]

17
OembedTests.csproj Normal file
View File

@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>5a8aa1d4-191d-41df-a985-bd3376a38224</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>.</DockerfileContext>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.6" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>
</Project>

6
OembedTests.http Normal file
View File

@@ -0,0 +1,6 @@
@OembedTests_HostAddress = http://localhost:5052
GET {{OembedTests_HostAddress}}/weatherforecast/
Accept: application/json
###

25
OembedTests.sln Normal file
View File

@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.9.34728.123
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OembedTests", "OembedTests.csproj", "{4E788BB3-1E69-4EA5-A4C3-BF89F97CACED}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4E788BB3-1E69-4EA5-A4C3-BF89F97CACED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4E788BB3-1E69-4EA5-A4C3-BF89F97CACED}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4E788BB3-1E69-4EA5-A4C3-BF89F97CACED}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4E788BB3-1E69-4EA5-A4C3-BF89F97CACED}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F81C49C6-5456-40F1-997C-812D773364B6}
EndGlobalSection
EndGlobal

36
Program.cs Normal file
View File

@@ -0,0 +1,36 @@
namespace OembedTests
{
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();
}
}
}

View File

@@ -0,0 +1,52 @@
{
"profiles": {
"http": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "http://localhost:5052"
},
"https": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "https://localhost:7250;http://localhost:5052"
},
"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:26517",
"sslPort": 44326
}
}
}

13
WeatherForecast.cs Normal file
View File

@@ -0,0 +1,13 @@
namespace OembedTests
{
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; }
}
}

View File

@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

9
appsettings.json Normal file
View File

@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}