Skip to content
This repository was archived by the owner on Sep 28, 2021. It is now read-only.

2017 05 #6

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<<<<<<< HEAD
# Code samples from Microservices in .NET Core
The code samples from my microservices book - https://manning.com/books/microservices-in-net-core

Expand Down
23 changes: 23 additions & 0 deletions src/Chapter01/HelloMicroservices/HelloMicroservices.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
<AssemblyName>HelloMicroservices</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>HelloMicroservices</PackageId>
</PropertyGroup>

<ItemGroup>
<None Update="wwwroot\**\*">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Owin" Version="1.1.2" />
<PackageReference Include="Nancy" Version="2.0.0-clinteastwood" />
</ItemGroup>

</Project>
19 changes: 0 additions & 19 deletions src/Chapter01/HelloMicroservices/HelloMicroservices.xproj

This file was deleted.

49 changes: 0 additions & 49 deletions src/Chapter01/HelloMicroservices/project.json

This file was deleted.

8 changes: 4 additions & 4 deletions src/Chapter01/ch01.sln
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@


Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
# Visual Studio 15
VisualStudioVersion = 15.0.26114.2
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "HelloMicroservices", "HelloMicroservices\HelloMicroservices.xproj", "{74316F9A-D6B2-451A-B709-B3DC753D9A8C}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloMicroservices", "HelloMicroservices\HelloMicroservices.csproj", "{74316F9A-D6B2-451A-B709-B3DC753D9A8C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
21 changes: 21 additions & 0 deletions src/Chapter02/ShoppingCart/ShoppingCart.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp1.0</TargetFramework>
<AssemblyName>ShoppingCart</AssemblyName>
<PackageId>ShoppingCart</PackageId>
<PackageTargetFallback>$(PackageTargetFallback);dotnet5.6;dnxcore50;portable-net45+win8</PackageTargetFallback>
</PropertyGroup>
<ItemGroup>
<None Update="wwwroot\**\*">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Owin" Version="1.1.2"/>
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.1.2" />
<PackageReference Include="System.Net.Http" Version="4.3.2" />
<PackageReference Include="Nancy" Version="2.0.0-clienteastwood" />
<PackageReference Include="Polly" Version="4.2.1" />
</ItemGroup>
</Project>
19 changes: 0 additions & 19 deletions src/Chapter02/ShoppingCart/ShoppingCart.xproj

This file was deleted.

52 changes: 0 additions & 52 deletions src/Chapter02/ShoppingCart/project.json

This file was deleted.

8 changes: 4 additions & 4 deletions src/Chapter02/ch02.sln
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@


Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
# Visual Studio 15
VisualStudioVersion = 15.0.26114.2
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ShoppingCart", "ShoppingCart\ShoppingCart.xproj", "{10E4F601-C16B-4936-A7B4-D32D799318D1}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShoppingCart", "ShoppingCart\ShoppingCart.csproj", "{10E4F601-C16B-4936-A7B4-D32D799318D1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
16 changes: 16 additions & 0 deletions src/Chapter04/ApiGatewayMock/ApiGatewayMock.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
<AssemblyName>ApiGatewayMock</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>ApiGatewayMock</PackageId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="10.0.2" />
<PackageReference Include="Polly" Version="5.1.0" />
<PackageReference Include="System.Net.Http" Version="4.3.2" />
</ItemGroup>

</Project>
19 changes: 0 additions & 19 deletions src/Chapter04/ApiGatewayMock/ApiGatewayMock.xproj

This file was deleted.

7 changes: 6 additions & 1 deletion src/Chapter04/ApiGatewayMock/LoyalProgramClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

namespace ApiGatewayMock
{
using System.Net.Http.Headers;

public class LoyaltyProgramClient
{
private static Policy exponentialRetryPolicy =
Expand Down Expand Up @@ -35,6 +37,7 @@ private async Task<HttpResponseMessage> DoUserQuery(int userId)
var userResource = $"/users/{userId}";
using(var httpClient = new HttpClient())
{
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
httpClient.BaseAddress = new Uri($"http://{this.hostName}");
var response = await httpClient.GetAsync(userResource);
ThrowOnTransientFailure(response);
Expand All @@ -55,7 +58,8 @@ public async Task<HttpResponseMessage> RegisterUser(LoyaltyProgramUser newUser)
private async Task<HttpResponseMessage> DoRegisterUser(LoyaltyProgramUser newUser)
{
using(var httpClient = new HttpClient())
{
{
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
httpClient.BaseAddress = new Uri($"http://{this.hostName}");
var response = await httpClient.PostAsync("/users/", new StringContent(JsonConvert.SerializeObject(newUser), Encoding.UTF8, "application/json"));
ThrowOnTransientFailure(response);
Expand All @@ -72,6 +76,7 @@ private async Task<HttpResponseMessage> DoUpdateUser(LoyaltyProgramUser user)
{
using(var httpClient = new HttpClient())
{
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
httpClient.BaseAddress = new Uri($"http://{this.hostName}");
var response = await httpClient.PutAsync($"/users/{user.Id}", new StringContent(JsonConvert.SerializeObject(user), Encoding.UTF8, "application/json"));
ThrowOnTransientFailure(response);
Expand Down
4 changes: 2 additions & 2 deletions src/Chapter04/ApiGatewayMock/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public void Main()
WriteLine("********************");
WriteLine("Choose one of:");
WriteLine("q <userid> - to query the Loyalty Program Microservice for a user with id <userid>.");
WriteLine("r <userid> - to register a user with id <userid> with the Loyalty Program Microservice.");
WriteLine("u <userid> <interests> - to update a user with new comman separated interests");
WriteLine("r <name> - to register a user with id <userid> with the Loyalty Program Microservice.");
WriteLine("u <userid> <interests> - to update a user with new interests");
WriteLine("exit - to exit");
WriteLine("********************");
var cmd = ReadLine();
Expand Down
26 changes: 0 additions & 26 deletions src/Chapter04/ApiGatewayMock/project.json

This file was deleted.

12 changes: 6 additions & 6 deletions src/Chapter04/Ch4.sln
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@


Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25123.0
# Visual Studio 15
VisualStudioVersion = 15.0.26114.2
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "LoyaltyProgram", "LoyaltyProgram\LoyaltyProgram.xproj", "{4BED3C45-E8C3-4345-A08F-249A39A256EB}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LoyaltyProgram", "LoyaltyProgram\LoyaltyProgram.csproj", "{4BED3C45-E8C3-4345-A08F-249A39A256EB}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ApiGatewayMock", "ApiGatewayMock\ApiGatewayMock.xproj", "{FE109A02-BF1B-46FC-87C8-2A68781CE8A4}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ApiGatewayMock", "ApiGatewayMock\ApiGatewayMock.csproj", "{FE109A02-BF1B-46FC-87C8-2A68781CE8A4}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "LoyaltyProgramEventConsumer", "LoyaltyProgramEventConsumer\LoyaltyProgramEventConsumer.xproj", "{47349717-585A-43EE-96E8-7D5249CB431D}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LoyaltyProgramEventConsumer", "LoyaltyProgramEventConsumer\LoyaltyProgramEventConsumer.csproj", "{47349717-585A-43EE-96E8-7D5249CB431D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
18 changes: 18 additions & 0 deletions src/Chapter04/LoyaltyProgram/LoyaltyProgram.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
<AssemblyName>LoyaltyProgram</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>LoyaltyProgram</PackageId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Owin" Version="1.1.2" />
<PackageReference Include="Nancy" Version="2.0.0-clinteastwood" />
<PackageReference Include="YamlDotNet" Version="4.2.1" />
</ItemGroup>

</Project>
19 changes: 0 additions & 19 deletions src/Chapter04/LoyaltyProgram/LoyaltyProgram.xproj

This file was deleted.

Loading