Skip to content

Commit

Permalink
Merge pull request #1 from CorrelatorSharp/feature-create-aspnetcore
Browse files Browse the repository at this point in the history
Netstandard / AspNetCore 2 MVC
  • Loading branch information
jasond-s authored Feb 14, 2018
2 parents 067c1f1 + 9d5b547 commit 8f684af
Show file tree
Hide file tree
Showing 14 changed files with 288 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -285,4 +285,4 @@ __pycache__/
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
*.xsd.cs
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}" };
}
}
}
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>
18 changes: 18 additions & 0 deletions CorrelatorSharp.AspNetCore.Mvc.Sample/Program.cs
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();
}
}
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/"
}
}
}
36 changes: 36 additions & 0 deletions CorrelatorSharp.AspNetCore.Mvc.Sample/Startup.cs
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 CorrelatorSharp.AspNetCore.Mvc.Sample/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
}
}
15 changes: 15 additions & 0 deletions CorrelatorSharp.AspNetCore.Mvc.Sample/appsettings.json
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"
}
}
}
}
36 changes: 36 additions & 0 deletions CorrelatorSharp.AspNetCore.Mvc.sln
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 CorrelatorSharp.AspNetCore.Mvc/CorrelationIdActionFilter.cs
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);
}
}
}
}
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>
3 changes: 2 additions & 1 deletion LICENSE → LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
MIT License
The MIT License (MIT)

Copyright (c) 2018 CorrelatorSharp

Expand All @@ -19,3 +19,4 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

3 changes: 3 additions & 0 deletions README.md
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)
39 changes: 39 additions & 0 deletions appveyor.yml
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

0 comments on commit 8f684af

Please sign in to comment.