Skip to content

Commit dc27e5f

Browse files
author
DESKTOP-9UGN8H4\PC
committed
Initial commit
0 parents commit dc27e5f

File tree

140 files changed

+10254
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+10254
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using Docker_Redis_Sample.Core;
2+
using Docker_Redis_Sample.Service;
3+
using Microsoft.AspNetCore.Http;
4+
using Microsoft.AspNetCore.Mvc;
5+
6+
namespace Docker_Redis_Sample.API.Controllers
7+
{
8+
[Route("api/[controller]")]
9+
[ApiController]
10+
public class ValuesController : ControllerBase
11+
{
12+
private IValuesService _valuesService;
13+
14+
public ValuesController(IValuesService valuesService)
15+
{
16+
_valuesService = valuesService;
17+
}
18+
19+
[HttpGet("{id}")]
20+
public ValuesModel GetValuesById(int id)
21+
{
22+
ValuesModel values = _valuesService.getValuesById(id);
23+
return values;
24+
}
25+
}
26+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net5.0</TargetFramework>
5+
<RootNamespace>Docker_Redis_Sample.API</RootNamespace>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
10+
</ItemGroup>
11+
12+
<ItemGroup>
13+
<ProjectReference Include="..\Docker-Redis-Sample.Cache\Docker-Redis-Sample.Cache.csproj" />
14+
<ProjectReference Include="..\Docker-Redis-Sample.Core\Docker-Redis-Sample.Core.csproj" />
15+
<ProjectReference Include="..\Docker-Redis-Sample.Service\Docker-Redis-Sample.Service.csproj" />
16+
</ItemGroup>
17+
18+
</Project>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Controller_SelectedScaffolderID>ApiControllerEmptyScaffolder</Controller_SelectedScaffolderID>
5+
<Controller_SelectedScaffolderCategoryPath>root/Common/Api</Controller_SelectedScaffolderCategoryPath>
6+
</PropertyGroup>
7+
</Project>

Docker-Redis-Sample.API/Program.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using Microsoft.AspNetCore.Hosting;
2+
using Microsoft.Extensions.Configuration;
3+
using Microsoft.Extensions.Hosting;
4+
using Microsoft.Extensions.Logging;
5+
using System;
6+
using System.Collections.Generic;
7+
using System.Linq;
8+
using System.Threading.Tasks;
9+
10+
namespace Docker_Redis_Sample.API
11+
{
12+
public class Program
13+
{
14+
public static void Main(string[] args)
15+
{
16+
CreateHostBuilder(args).Build().Run();
17+
}
18+
19+
public static IHostBuilder CreateHostBuilder(string[] args) =>
20+
Host.CreateDefaultBuilder(args)
21+
.ConfigureWebHostDefaults(webBuilder =>
22+
{
23+
webBuilder.UseStartup<Startup>();
24+
});
25+
}
26+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"$schema": "http://json.schemastore.org/launchsettings.json",
3+
"iisSettings": {
4+
"windowsAuthentication": false,
5+
"anonymousAuthentication": true,
6+
"iisExpress": {
7+
"applicationUrl": "http://localhost:62750",
8+
"sslPort": 0
9+
}
10+
},
11+
"profiles": {
12+
"IIS Express": {
13+
"commandName": "IISExpress",
14+
"launchBrowser": true,
15+
"launchUrl": "swagger",
16+
"environmentVariables": {
17+
"ASPNETCORE_ENVIRONMENT": "Development"
18+
}
19+
},
20+
"Docker_Redis_Sample.API": {
21+
"commandName": "Project",
22+
"dotnetRunMessages": "true",
23+
"launchBrowser": true,
24+
"launchUrl": "swagger",
25+
"applicationUrl": "http://localhost:5000",
26+
"environmentVariables": {
27+
"ASPNETCORE_ENVIRONMENT": "Development"
28+
}
29+
}
30+
}
31+
}

Docker-Redis-Sample.API/Startup.cs

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
using Docker_Redis_Sample.Cache;
2+
using Docker_Redis_Sample.Cache.Redis;
3+
using Docker_Redis_Sample.Service;
4+
using Microsoft.AspNetCore.Builder;
5+
using Microsoft.AspNetCore.Hosting;
6+
using Microsoft.AspNetCore.Mvc;
7+
using Microsoft.Extensions.Configuration;
8+
using Microsoft.Extensions.DependencyInjection;
9+
using Microsoft.Extensions.Hosting;
10+
using Microsoft.Extensions.Logging;
11+
using Microsoft.OpenApi.Models;
12+
using System;
13+
using System.Collections.Generic;
14+
using System.Linq;
15+
using System.Threading.Tasks;
16+
17+
namespace Docker_Redis_Sample.API
18+
{
19+
public class Startup
20+
{
21+
public Startup(IConfiguration configuration)
22+
{
23+
Configuration = configuration;
24+
}
25+
26+
public IConfiguration Configuration { get; }
27+
28+
// This method gets called by the runtime. Use this method to add services to the container.
29+
public void ConfigureServices(IServiceCollection services)
30+
{
31+
32+
services.AddControllers();
33+
services.AddScoped<IValuesService, ValuesService>();
34+
services.AddSingleton<RedisServer>();
35+
services.AddSingleton<ICacheManager, RedisCacheManager>();
36+
services.AddSwaggerGen(c =>
37+
{
38+
c.SwaggerDoc("v1", new OpenApiInfo { Title = "Docker_Redis_Sample.API", Version = "v1" });
39+
});
40+
}
41+
42+
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
43+
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
44+
{
45+
if (env.IsDevelopment())
46+
{
47+
app.UseDeveloperExceptionPage();
48+
app.UseSwagger();
49+
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "Docker_Redis_Sample.API v1"));
50+
}
51+
52+
app.UseRouting();
53+
54+
app.UseAuthorization();
55+
56+
app.UseEndpoints(endpoints =>
57+
{
58+
endpoints.MapControllers();
59+
});
60+
}
61+
}
62+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft": "Warning",
6+
"Microsoft.Hosting.Lifetime": "Information"
7+
}
8+
}
9+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft": "Warning",
6+
"Microsoft.Hosting.Lifetime": "Information"
7+
}
8+
},
9+
"RedisSettings": {
10+
"RedisConnectionString": "redis-sample:6379"
11+
},
12+
"AllowedHosts": "*"
13+
}

0 commit comments

Comments
 (0)