Skip to content

Commit d090ed7

Browse files
authored
Add files via upload
1 parent f6a1936 commit d090ed7

File tree

73 files changed

+1613
-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.

73 files changed

+1613
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +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+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +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>
Original file line numberDiff line numberDiff line change
@@ -0,0 +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>
9+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,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
@@ -0,0 +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();
Original file line numberDiff line numberDiff line change
@@ -0,0 +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+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +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+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft.AspNetCore": "Warning"
6+
}
7+
}
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,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
@@ -0,0 +1,126 @@
1+
{
2+
"runtimeTarget": {
3+
"name": ".NETCoreApp,Version=v8.0",
4+
"signature": ""
5+
},
6+
"compilationOptions": {},
7+
"targets": {
8+
".NETCoreApp,Version=v8.0": {
9+
"HogwartsAPI/1.0.0": {
10+
"dependencies": {
11+
"Swashbuckle.AspNetCore": "6.4.0",
12+
"TypedHttpClient": "1.0.0"
13+
},
14+
"runtime": {
15+
"HogwartsAPI.dll": {}
16+
}
17+
},
18+
"Microsoft.Extensions.ApiDescription.Server/6.0.5": {},
19+
"Microsoft.OpenApi/1.2.3": {
20+
"runtime": {
21+
"lib/netstandard2.0/Microsoft.OpenApi.dll": {
22+
"assemblyVersion": "1.2.3.0",
23+
"fileVersion": "1.2.3.0"
24+
}
25+
}
26+
},
27+
"Swashbuckle.AspNetCore/6.4.0": {
28+
"dependencies": {
29+
"Microsoft.Extensions.ApiDescription.Server": "6.0.5",
30+
"Swashbuckle.AspNetCore.Swagger": "6.4.0",
31+
"Swashbuckle.AspNetCore.SwaggerGen": "6.4.0",
32+
"Swashbuckle.AspNetCore.SwaggerUI": "6.4.0"
33+
}
34+
},
35+
"Swashbuckle.AspNetCore.Swagger/6.4.0": {
36+
"dependencies": {
37+
"Microsoft.OpenApi": "1.2.3"
38+
},
39+
"runtime": {
40+
"lib/net6.0/Swashbuckle.AspNetCore.Swagger.dll": {
41+
"assemblyVersion": "6.4.0.0",
42+
"fileVersion": "6.4.0.0"
43+
}
44+
}
45+
},
46+
"Swashbuckle.AspNetCore.SwaggerGen/6.4.0": {
47+
"dependencies": {
48+
"Swashbuckle.AspNetCore.Swagger": "6.4.0"
49+
},
50+
"runtime": {
51+
"lib/net6.0/Swashbuckle.AspNetCore.SwaggerGen.dll": {
52+
"assemblyVersion": "6.4.0.0",
53+
"fileVersion": "6.4.0.0"
54+
}
55+
}
56+
},
57+
"Swashbuckle.AspNetCore.SwaggerUI/6.4.0": {
58+
"runtime": {
59+
"lib/net6.0/Swashbuckle.AspNetCore.SwaggerUI.dll": {
60+
"assemblyVersion": "6.4.0.0",
61+
"fileVersion": "6.4.0.0"
62+
}
63+
}
64+
},
65+
"TypedHttpClient/1.0.0": {
66+
"runtime": {
67+
"TypedHttpClient.dll": {}
68+
}
69+
}
70+
}
71+
},
72+
"libraries": {
73+
"HogwartsAPI/1.0.0": {
74+
"type": "project",
75+
"serviceable": false,
76+
"sha512": ""
77+
},
78+
"Microsoft.Extensions.ApiDescription.Server/6.0.5": {
79+
"type": "package",
80+
"serviceable": true,
81+
"sha512": "sha512-Ckb5EDBUNJdFWyajfXzUIMRkhf52fHZOQuuZg/oiu8y7zDCVwD0iHhew6MnThjHmevanpxL3f5ci2TtHQEN6bw==",
82+
"path": "microsoft.extensions.apidescription.server/6.0.5",
83+
"hashPath": "microsoft.extensions.apidescription.server.6.0.5.nupkg.sha512"
84+
},
85+
"Microsoft.OpenApi/1.2.3": {
86+
"type": "package",
87+
"serviceable": true,
88+
"sha512": "sha512-Nug3rO+7Kl5/SBAadzSMAVgqDlfGjJZ0GenQrLywJ84XGKO0uRqkunz5Wyl0SDwcR71bAATXvSdbdzPrYRYKGw==",
89+
"path": "microsoft.openapi/1.2.3",
90+
"hashPath": "microsoft.openapi.1.2.3.nupkg.sha512"
91+
},
92+
"Swashbuckle.AspNetCore/6.4.0": {
93+
"type": "package",
94+
"serviceable": true,
95+
"sha512": "sha512-eUBr4TW0up6oKDA5Xwkul289uqSMgY0xGN4pnbOIBqCcN9VKGGaPvHX3vWaG/hvocfGDP+MGzMA0bBBKz2fkmQ==",
96+
"path": "swashbuckle.aspnetcore/6.4.0",
97+
"hashPath": "swashbuckle.aspnetcore.6.4.0.nupkg.sha512"
98+
},
99+
"Swashbuckle.AspNetCore.Swagger/6.4.0": {
100+
"type": "package",
101+
"serviceable": true,
102+
"sha512": "sha512-nl4SBgGM+cmthUcpwO/w1lUjevdDHAqRvfUoe4Xp/Uvuzt9mzGUwyFCqa3ODBAcZYBiFoKvrYwz0rabslJvSmQ==",
103+
"path": "swashbuckle.aspnetcore.swagger/6.4.0",
104+
"hashPath": "swashbuckle.aspnetcore.swagger.6.4.0.nupkg.sha512"
105+
},
106+
"Swashbuckle.AspNetCore.SwaggerGen/6.4.0": {
107+
"type": "package",
108+
"serviceable": true,
109+
"sha512": "sha512-lXhcUBVqKrPFAQF7e/ZeDfb5PMgE8n5t6L5B6/BQSpiwxgHzmBcx8Msu42zLYFTvR5PIqE9Q9lZvSQAcwCxJjw==",
110+
"path": "swashbuckle.aspnetcore.swaggergen/6.4.0",
111+
"hashPath": "swashbuckle.aspnetcore.swaggergen.6.4.0.nupkg.sha512"
112+
},
113+
"Swashbuckle.AspNetCore.SwaggerUI/6.4.0": {
114+
"type": "package",
115+
"serviceable": true,
116+
"sha512": "sha512-1Hh3atb3pi8c+v7n4/3N80Jj8RvLOXgWxzix6w3OZhB7zBGRwsy7FWr4e3hwgPweSBpwfElqj4V4nkjYabH9nQ==",
117+
"path": "swashbuckle.aspnetcore.swaggerui/6.4.0",
118+
"hashPath": "swashbuckle.aspnetcore.swaggerui.6.4.0.nupkg.sha512"
119+
},
120+
"TypedHttpClient/1.0.0": {
121+
"type": "project",
122+
"serviceable": false,
123+
"sha512": ""
124+
}
125+
}
126+
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"runtimeOptions": {
3+
"tfm": "net8.0",
4+
"frameworks": [
5+
{
6+
"name": "Microsoft.NETCore.App",
7+
"version": "8.0.0"
8+
},
9+
{
10+
"name": "Microsoft.AspNetCore.App",
11+
"version": "8.0.0"
12+
}
13+
],
14+
"configProperties": {
15+
"System.GC.Server": true,
16+
"System.Globalization.Invariant": true,
17+
"System.Globalization.PredefinedCulturesOnly": true,
18+
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
19+
}
20+
}
21+
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft.AspNetCore": "Warning"
6+
}
7+
}
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft.AspNetCore": "Warning"
6+
}
7+
},
8+
"AllowedHosts": "*"
9+
}

0 commit comments

Comments
 (0)