-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from CorrelatorSharp/feature-create-aspnetcore
Netstandard / AspNetCore 2 MVC
- Loading branch information
Showing
14 changed files
with
288 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -285,4 +285,4 @@ __pycache__/ | |
*.btp.cs | ||
*.btm.cs | ||
*.odx.cs | ||
*.xsd.cs | ||
*.xsd.cs |
15 changes: 15 additions & 0 deletions
15
CorrelatorSharp.AspNetCore.Mvc.Sample/Controllers/ValuesController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System.Collections.Generic; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace CorrelatorSharp.AspNetCore.Mvc.Sample.Controllers | ||
{ | ||
[Route("api/[controller]")] | ||
public class ValuesController : Controller | ||
{ | ||
[HttpGet] | ||
public IEnumerable<string> Get() | ||
{ | ||
return new [] { $"CorrelatorSharp.AspNetCore.Mvc - {ActivityScope.Current.Id}" }; | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
CorrelatorSharp.AspNetCore.Mvc.Sample/CorrelatorSharp.AspNetCore.Mvc.Sample.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp2.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Folder Include="wwwroot\" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.5" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.2" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\CorrelatorSharp.AspNetCore.Mvc\CorrelatorSharp.AspNetCore.Mvc.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Microsoft.AspNetCore; | ||
using Microsoft.AspNetCore.Hosting; | ||
|
||
namespace CorrelatorSharp.AspNetCore.Mvc.Sample | ||
{ | ||
public class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
BuildWebHost(args).Run(); | ||
} | ||
|
||
public static IWebHost BuildWebHost(string[] args) => | ||
WebHost.CreateDefaultBuilder(args) | ||
.UseStartup<Startup>() | ||
.Build(); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
CorrelatorSharp.AspNetCore.Mvc.Sample/Properties/launchSettings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"iisSettings": { | ||
"windowsAuthentication": false, | ||
"anonymousAuthentication": true, | ||
"iisExpress": { | ||
"applicationUrl": "http://localhost:17768/", | ||
"sslPort": 0 | ||
} | ||
}, | ||
"profiles": { | ||
"IIS Express": { | ||
"commandName": "IISExpress", | ||
"launchBrowser": true, | ||
"launchUrl": "api/values", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
}, | ||
"CorrelatorSharp.AspNetCore.Mvc.Sample": { | ||
"commandName": "Project", | ||
"launchBrowser": true, | ||
"launchUrl": "api/values", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
}, | ||
"applicationUrl": "http://localhost:17769/" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using CorrelatorSharp.AspNetCore.Mvc; | ||
|
||
namespace CorrelatorSharp.AspNetCore.Mvc.Sample | ||
{ | ||
public class Startup | ||
{ | ||
public Startup(IConfiguration configuration) | ||
{ | ||
Configuration = configuration; | ||
} | ||
|
||
public IConfiguration Configuration { get; } | ||
|
||
public void ConfigureServices(IServiceCollection services) | ||
{ | ||
services.AddMvc(configuration => | ||
{ | ||
configuration.Filters.Add(new CorrelationIdActionFilter()); | ||
}); | ||
} | ||
|
||
public void Configure(IApplicationBuilder app, IHostingEnvironment env) | ||
{ | ||
if (env.IsDevelopment()) | ||
{ | ||
app.UseDeveloperExceptionPage(); | ||
} | ||
|
||
app.UseMvc(); | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
CorrelatorSharp.AspNetCore.Mvc.Sample/appsettings.Development.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"Logging": { | ||
"IncludeScopes": false, | ||
"LogLevel": { | ||
"Default": "Debug", | ||
"System": "Information", | ||
"Microsoft": "Information" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"Logging": { | ||
"IncludeScopes": false, | ||
"Debug": { | ||
"LogLevel": { | ||
"Default": "Warning" | ||
} | ||
}, | ||
"Console": { | ||
"LogLevel": { | ||
"Default": "Warning" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 15 | ||
VisualStudioVersion = 15.0.27130.2027 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{4E3762CD-2D68-412B-BF2A-E262944CB6E4}" | ||
ProjectSection(SolutionItems) = preProject | ||
appveyor.yml = appveyor.yml | ||
EndProjectSection | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CorrelatorSharp.AspNetCore.Mvc", "CorrelatorSharp.AspNetCore.Mvc\CorrelatorSharp.AspNetCore.Mvc.csproj", "{45A946EC-29CE-4513-9F55-A666A2986FD1}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CorrelatorSharp.AspNetCore.Mvc.Sample", "CorrelatorSharp.AspNetCore.Mvc.Sample\CorrelatorSharp.AspNetCore.Mvc.Sample.csproj", "{4E060050-6924-4248-8584-0EA0CA239383}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{45A946EC-29CE-4513-9F55-A666A2986FD1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{45A946EC-29CE-4513-9F55-A666A2986FD1}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{45A946EC-29CE-4513-9F55-A666A2986FD1}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{45A946EC-29CE-4513-9F55-A666A2986FD1}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{4E060050-6924-4248-8584-0EA0CA239383}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{4E060050-6924-4248-8584-0EA0CA239383}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{4E060050-6924-4248-8584-0EA0CA239383}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{4E060050-6924-4248-8584-0EA0CA239383}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {A257831B-2504-49D5-A869-3F2AEFF581B4} | ||
EndGlobalSection | ||
EndGlobal |
36 changes: 36 additions & 0 deletions
36
CorrelatorSharp.AspNetCore.Mvc/CorrelationIdActionFilter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Mvc.Filters; | ||
|
||
namespace CorrelatorSharp.AspNetCore.Mvc | ||
{ | ||
public class CorrelationIdActionFilter : IAsyncActionFilter | ||
{ | ||
private static readonly string CorrelationIdHttpHeader = Headers.CorrelationId; | ||
|
||
public bool AllowMultiple => false; | ||
|
||
public async Task OnActionExecutionAsync(ActionExecutingContext actionContext, ActionExecutionDelegate next) | ||
{ | ||
string correlationId = null; | ||
|
||
var headers = actionContext.HttpContext.Request?.Headers; | ||
if (headers != null && headers.TryGetValue(CorrelationIdHttpHeader, out var correlationHeaderValue)) | ||
{ | ||
correlationId = correlationHeaderValue; | ||
} | ||
|
||
if (string.IsNullOrWhiteSpace(correlationId)) | ||
{ | ||
correlationId = Guid.NewGuid().ToString(); | ||
} | ||
|
||
using (var scope = ActivityScope.New(null, correlationId)) | ||
{ | ||
var actionResult = await next.Invoke(); | ||
|
||
actionResult.HttpContext.Response.Headers.Add(CorrelationIdHttpHeader, scope.Id); | ||
} | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
CorrelatorSharp.AspNetCore.Mvc/CorrelatorSharp.AspNetCore.Mvc.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<PackageId>CorrelatorSharp.AspNetCore.Mvc</PackageId> | ||
|
||
<Version>1.0.0</Version> | ||
|
||
<!--Bump the assembly version only on major releases--> | ||
<AssemblyVersion>1.1.0.0</AssemblyVersion> | ||
|
||
<AssemblyName>CorrelatorSharp.AspNetCore.Mvc</AssemblyName> | ||
<Description>CorrelatorSharp, a set of tools for adding correlation identifiers for actions performed by users and machine across your applications. Your one stop shop for context-aware logging and diagnostics.</Description> | ||
<Authors>Ivan Zlatev, Jason Dryhurst-Smith</Authors> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<PackageTags>context;correlation;logging;diagnostics</PackageTags> | ||
<PackageProjectUrl>https://github.com/CorrelatorSharp/CorrelatorSharp</PackageProjectUrl> | ||
<PackageLicenseUrl>https://github.com/CorrelatorSharp/CorrelatorSharp/blob/master/LICENSE.txt</PackageLicenseUrl> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="CorrelatorSharp" Version="[1.4.0,2)" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="[2.0,3)" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
# CorrelatorSharp.AspNetCore.Mvc | ||
|
||
CorrelatorSharp bindings for AspNetCore MVC framework. | ||
|
||
Documentation: [http://correlatorsharp.github.io/dotnet/aspnetcore.html](http://correlatorsharp.github.io/dotnet/aspnetcore.html) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
environment: | ||
package_version: '1.0.0' | ||
assembly_version: '1.1.0.0' | ||
|
||
version: '$(package_version)+{build}' | ||
|
||
image: Visual Studio 2017 | ||
|
||
dotnet_csproj: | ||
patch: true | ||
file: '**\*.csproj' | ||
version: '$(package_version)' | ||
assembly_version: '$(assembly_version)' | ||
|
||
configuration: Release | ||
|
||
before_build: dotnet restore | ||
|
||
build: | ||
publish_nuget: true | ||
publish_nuget_symbols: true | ||
verbosity: minimal | ||
|
||
deploy: | ||
- provider: GitHub | ||
description: | | ||
* Create a package for the AspNetCore 2.0 MVC framework | ||
on: | ||
appveyor_repo_tag: true | ||
|
||
release: v$(package_version) | ||
auth_token: | ||
secure: y4HfARa+GScoSgdsOIb7A3L8TV93/wiPBgJENisycZ6yKwBANmPEe1MesK4IC6rm | ||
|
||
- provider: NuGet | ||
api_key: | ||
secure: vZC+uEZj00A+9riSWLXqdnPtGa96W9SQkBy30dS2D5bOUdvteU9vOAP69QLJrY/o | ||
on: | ||
appveyor_repo_tag: true |