Skip to content

Commit 602805e

Browse files
committed
Renamed solution
1 parent dd840d8 commit 602805e

File tree

74 files changed

+249
-1612
lines changed

Some content is hidden

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

74 files changed

+249
-1612
lines changed

.gitignore

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
################################################################################
2+
# This .gitignore file was automatically created by Microsoft(R) Visual Studio.
3+
################################################################################
4+
5+
/.vs
6+
/TypedHttpClientSolution/HogwartsAPI/bin/Debug/net8.0
7+
/TypedHttpClientSolution/HogwartsAPI/obj
8+
/TypedHttpClientSolution/TypedHttpClient/.vs
9+
/TypedHttpClientSolution/TypedHttpClient/bin/Debug/net8.0
10+
/TypedHttpClientSolution/TypedHttpClient/obj
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
1-
using Microsoft.AspNetCore.Mvc;
2-
using System.Text.Json;
3-
using TypedHttpClientNamespace;
4-
5-
namespace HogwartsAPI.Controllers
6-
{
7-
[ApiController]
8-
[Route("[controller]")]
9-
public class HogwartsController : ControllerBase
10-
{
11-
private ITypedHttpClient _typedHttpClient;
12-
private readonly ILogger<HogwartsController> _logger;
13-
14-
public HogwartsController(ILogger<HogwartsController> logger, ITypedHttpClient typedHttpClient)
15-
{
16-
_logger = logger;
17-
_typedHttpClient = typedHttpClient;
18-
}
19-
20-
[Route("Students"), HttpGet]
21-
public async Task<HttpResponseMessage> Students()
22-
{
23-
return await _typedHttpClient.Execute("http://www.hogwarts.com/students", HttpMethod.Get);
24-
}
25-
26-
[Route("Student"), HttpGet]
27-
public async Task<HttpResponseMessage> Student(Guid studentId)
28-
{
29-
return await _typedHttpClient.Execute("http://www.hogwarts.com/students/" + studentId, HttpMethod.Get);
30-
}
31-
32-
[Route("Student"), HttpPost]
33-
public async Task<HttpResponseMessage> Student(Student student)
34-
{
35-
return await _typedHttpClient.Execute("http://www.hogwarts.com/student", HttpMethod.Post, new StringContent(JsonSerializer.Serialize(student)));
36-
}
37-
}
38-
}
1+
using Microsoft.AspNetCore.Mvc;
2+
using System.Text.Json;
3+
using TypedHttpClientNamespace;
4+
5+
namespace HogwartsAPI.Controllers
6+
{
7+
[ApiController]
8+
[Route("[controller]")]
9+
public class HogwartsController : ControllerBase
10+
{
11+
private ITypedHttpClient _typedHttpClient;
12+
private readonly ILogger<HogwartsController> _logger;
13+
14+
public HogwartsController(ILogger<HogwartsController> logger, ITypedHttpClient typedHttpClient)
15+
{
16+
_logger = logger;
17+
_typedHttpClient = typedHttpClient;
18+
}
19+
20+
[Route("Students"), HttpGet]
21+
public async Task<HttpResponseMessage> Students()
22+
{
23+
return await _typedHttpClient.Execute("http://www.hogwarts.com/students", HttpMethod.Get);
24+
}
25+
26+
[Route("Student"), HttpGet]
27+
public async Task<HttpResponseMessage> Student(Guid studentId)
28+
{
29+
return await _typedHttpClient.Execute("http://www.hogwarts.com/students/" + studentId, HttpMethod.Get);
30+
}
31+
32+
[Route("Student"), HttpPost]
33+
public async Task<HttpResponseMessage> Student(Student student)
34+
{
35+
return await _typedHttpClient.Execute("http://www.hogwarts.com/student", HttpMethod.Post, new StringContent(JsonSerializer.Serialize(student)));
36+
}
37+
}
38+
}
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
<Project Sdk="Microsoft.NET.Sdk.Web">
2-
3-
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
5-
<Nullable>enable</Nullable>
6-
<ImplicitUsings>enable</ImplicitUsings>
7-
<InvariantGlobalization>true</InvariantGlobalization>
8-
</PropertyGroup>
9-
10-
<ItemGroup>
11-
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
12-
</ItemGroup>
13-
14-
<ItemGroup>
15-
<ProjectReference Include="..\TypedHttpClient\TypedHttpClient.csproj" />
16-
</ItemGroup>
17-
18-
</Project>
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<InvariantGlobalization>true</InvariantGlobalization>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
12+
</ItemGroup>
13+
14+
<ItemGroup>
15+
<ProjectReference Include="..\TypedHttpClient\TypedHttpClient.csproj" />
16+
</ItemGroup>
17+
18+
</Project>
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<PropertyGroup>
4-
<ActiveDebugProfile>IIS Express</ActiveDebugProfile>
5-
</PropertyGroup>
6-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
7-
<DebuggerFlavor>ProjectDebugger</DebuggerFlavor>
8-
</PropertyGroup>
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<ActiveDebugProfile>IIS Express</ActiveDebugProfile>
5+
</PropertyGroup>
6+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
7+
<DebuggerFlavor>ProjectDebugger</DebuggerFlavor>
8+
</PropertyGroup>
99
</Project>
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
@HogwartsAPI_HostAddress = http://localhost:5123
2-
3-
GET {{HogwartsAPI_HostAddress}}/Hogwarts/
4-
Accept: application/json
5-
6-
###
1+
@HogwartsAPI_HostAddress = http://localhost:5123
2+
3+
GET {{HogwartsAPI_HostAddress}}/Hogwarts/
4+
Accept: application/json
5+
6+
###
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
using TypedHttpClientNamespace;
2-
3-
var builder = WebApplication.CreateBuilder(args);
4-
5-
// Add services to the container.
6-
7-
builder.Services.AddControllers();
8-
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
9-
builder.Services.AddEndpointsApiExplorer();
10-
builder.Services.AddSwaggerGen();
11-
12-
builder.Services.AddHttpClient<ITypedHttpClient, TypedHttpClient>()
13-
.SetHandlerLifetime(TimeSpan.FromMinutes(5));
14-
15-
var app = builder.Build();
16-
17-
// Configure the HTTP request pipeline.
18-
if (app.Environment.IsDevelopment())
19-
{
20-
app.UseSwagger();
21-
app.UseSwaggerUI();
22-
}
23-
24-
app.UseHttpsRedirection();
25-
26-
app.UseAuthorization();
27-
28-
app.MapControllers();
29-
30-
app.Run();
1+
using TypedHttpClientNamespace;
2+
3+
var builder = WebApplication.CreateBuilder(args);
4+
5+
// Add services to the container.
6+
7+
builder.Services.AddControllers();
8+
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
9+
builder.Services.AddEndpointsApiExplorer();
10+
builder.Services.AddSwaggerGen();
11+
12+
builder.Services.AddHttpClient<ITypedHttpClient, TypedHttpClient>()
13+
.SetHandlerLifetime(TimeSpan.FromMinutes(5));
14+
15+
var app = builder.Build();
16+
17+
// Configure the HTTP request pipeline.
18+
if (app.Environment.IsDevelopment())
19+
{
20+
app.UseSwagger();
21+
app.UseSwaggerUI();
22+
}
23+
24+
app.UseHttpsRedirection();
25+
26+
app.UseAuthorization();
27+
28+
app.MapControllers();
29+
30+
app.Run();
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
1-
{
2-
"$schema": "http://json.schemastore.org/launchsettings.json",
3-
"iisSettings": {
4-
"windowsAuthentication": false,
5-
"anonymousAuthentication": true,
6-
"iisExpress": {
7-
"applicationUrl": "http://localhost:7649",
8-
"sslPort": 44346
9-
}
10-
},
11-
"profiles": {
12-
"http": {
13-
"commandName": "Project",
14-
"dotnetRunMessages": true,
15-
"launchBrowser": true,
16-
"launchUrl": "swagger",
17-
"applicationUrl": "http://localhost:5123",
18-
"environmentVariables": {
19-
"ASPNETCORE_ENVIRONMENT": "Development"
20-
}
21-
},
22-
"https": {
23-
"commandName": "Project",
24-
"dotnetRunMessages": true,
25-
"launchBrowser": true,
26-
"launchUrl": "swagger",
27-
"applicationUrl": "https://localhost:7252;http://localhost:5123",
28-
"environmentVariables": {
29-
"ASPNETCORE_ENVIRONMENT": "Development"
30-
}
31-
},
32-
"IIS Express": {
33-
"commandName": "IISExpress",
34-
"launchBrowser": true,
35-
"launchUrl": "swagger",
36-
"environmentVariables": {
37-
"ASPNETCORE_ENVIRONMENT": "Development"
38-
}
39-
}
40-
}
41-
}
1+
{
2+
"$schema": "http://json.schemastore.org/launchsettings.json",
3+
"iisSettings": {
4+
"windowsAuthentication": false,
5+
"anonymousAuthentication": true,
6+
"iisExpress": {
7+
"applicationUrl": "http://localhost:7649",
8+
"sslPort": 44346
9+
}
10+
},
11+
"profiles": {
12+
"http": {
13+
"commandName": "Project",
14+
"dotnetRunMessages": true,
15+
"launchBrowser": true,
16+
"launchUrl": "swagger",
17+
"applicationUrl": "http://localhost:5123",
18+
"environmentVariables": {
19+
"ASPNETCORE_ENVIRONMENT": "Development"
20+
}
21+
},
22+
"https": {
23+
"commandName": "Project",
24+
"dotnetRunMessages": true,
25+
"launchBrowser": true,
26+
"launchUrl": "swagger",
27+
"applicationUrl": "https://localhost:7252;http://localhost:5123",
28+
"environmentVariables": {
29+
"ASPNETCORE_ENVIRONMENT": "Development"
30+
}
31+
},
32+
"IIS Express": {
33+
"commandName": "IISExpress",
34+
"launchBrowser": true,
35+
"launchUrl": "swagger",
36+
"environmentVariables": {
37+
"ASPNETCORE_ENVIRONMENT": "Development"
38+
}
39+
}
40+
}
41+
}
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
namespace HogwartsAPI
2-
{
3-
public class Student
4-
{
5-
public Guid StudentId { get; set; }
6-
public string StudentName { get; set; }
7-
public string HouseName { get; set; }
8-
}
9-
}
1+
namespace HogwartsAPI
2+
{
3+
public class Student
4+
{
5+
public Guid StudentId { get; set; }
6+
public string StudentName { get; set; }
7+
public string HouseName { get; set; }
8+
}
9+
}
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
{
2-
"Logging": {
3-
"LogLevel": {
4-
"Default": "Information",
5-
"Microsoft.AspNetCore": "Warning"
6-
}
7-
}
8-
}
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft.AspNetCore": "Warning"
6+
}
7+
}
8+
}
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
{
2-
"Logging": {
3-
"LogLevel": {
4-
"Default": "Information",
5-
"Microsoft.AspNetCore": "Warning"
6-
}
7-
},
8-
"AllowedHosts": "*"
9-
}
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft.AspNetCore": "Warning"
6+
}
7+
},
8+
"AllowedHosts": "*"
9+
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
namespace TypedHttpClientNamespace
2-
{
3-
public interface ITypedHttpClient
4-
{
5-
Task<HttpResponseMessage> Execute(string uri, HttpMethod method, HttpContent? payload=null);
6-
}
7-
}
1+
namespace TypedHttpClientNamespace
2+
{
3+
public interface ITypedHttpClient
4+
{
5+
Task<HttpResponseMessage> Execute(string uri, HttpMethod method, HttpContent? payload=null);
6+
}
7+
}

0 commit comments

Comments
 (0)