Skip to content

Commit ccddf13

Browse files
author
Maxime Labelle
committed
New - Added definitions of support class and interface for tracking a REST API call.
1 parent bfe82d0 commit ccddf13

File tree

4 files changed

+202
-0
lines changed

4 files changed

+202
-0
lines changed

src/SpringComp.Interop/HttpEntry.cs

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
using System;
2+
using System.Collections.Generic;
3+
4+
namespace SpringComp.Owin.Interop
5+
{
6+
/// <summary>
7+
/// A simple class to hold details of an HTTP call.
8+
/// </summary>
9+
public sealed class HttpEntry
10+
{
11+
/// <summary>
12+
/// Initialize a new instance of the <see cref="HttpEntry" /> class.
13+
/// </summary>
14+
public HttpEntry()
15+
{
16+
TrackingId = Guid.NewGuid();
17+
CallDateTime = DateTime.UtcNow;
18+
}
19+
20+
/// <summary>
21+
/// An unique identifier for the HTTP call.
22+
/// </summary>
23+
public Guid TrackingId { get; private set; }
24+
25+
/// <summary>
26+
/// Identity of the caller.
27+
/// </summary>
28+
public string CallerIdentity { get; set; }
29+
30+
/// <summary>
31+
/// Timestamp at which the HTTP call took place.
32+
/// </summary>
33+
public DateTime CallDateTime { get; set; }
34+
35+
/// <summary>
36+
/// Verb associated with the HTTP call.
37+
/// </summary>
38+
public string Verb { get; set; }
39+
40+
/// <summary>
41+
/// Http request URI.
42+
/// </summary>
43+
public Uri RequestUri { get; set; }
44+
45+
/// <summary>
46+
/// Http request headers.
47+
/// </summary>
48+
public IDictionary<String, String[]> RequestHeaders { get; set; }
49+
50+
/// <summary>
51+
/// Http request content-length
52+
/// In the case of chunked transfer encoding,
53+
/// the request headers do not mention the content length.
54+
/// </summary>
55+
public long RequestLength { get; set; }
56+
57+
/// <summary>
58+
/// Http request body, if any.
59+
/// </summary>
60+
public string Request { get; set; }
61+
62+
/// <summary>
63+
/// Http response status code.
64+
/// </summary>
65+
public int StatusCode { get; set; }
66+
67+
/// <summary>
68+
/// Http response status line.
69+
/// </summary>
70+
public string ReasonPhrase { get; set; }
71+
72+
/// <summary>
73+
/// Http response headers.
74+
/// </summary>
75+
public IDictionary<String, String[]> ResponseHeaders { get; set; }
76+
77+
/// <summary>
78+
/// Http response content-length
79+
/// In the case of chunked transfer encoding,
80+
/// the response headers do not mention the content length.
81+
/// </summary>
82+
public long ResponseLength { get; set; }
83+
84+
/// <summary>
85+
/// Http response body.
86+
/// </summary>
87+
public string Response { get; set; }
88+
89+
90+
/// <summary>
91+
/// Timestamp representing the duration of the HTTP call.
92+
/// </summary>
93+
public TimeSpan CallDuration { get; set; }
94+
}
95+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System.Threading.Tasks;
2+
3+
namespace SpringComp.Owin.Interop
4+
{
5+
/// <summary>
6+
/// Interface for tracking details about HTTP calls.
7+
/// </summary>
8+
public interface IHttpTrackingStore
9+
{
10+
/// <summary>
11+
/// Persist details of an HTTP call into durable storage.
12+
/// </summary>
13+
/// <param name="record"></param>
14+
/// <returns></returns>
15+
Task InsertRecordAsync(HttpEntry record);
16+
}
17+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("SpringComp.Interop")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("SpringComp.Interop")]
13+
[assembly: AssemblyCopyright("Copyright © 2014")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("a0cc476e-9093-4af7-b7fd-b10762fd7894")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{D504F207-998E-41FE-B8F3-3EB6EED39DC0}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>SpringComp.Owin.Interop</RootNamespace>
11+
<AssemblyName>SpringComp.Owin.Interop</AssemblyName>
12+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
</PropertyGroup>
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16+
<DebugSymbols>true</DebugSymbols>
17+
<DebugType>full</DebugType>
18+
<Optimize>false</Optimize>
19+
<OutputPath>bin\Debug\</OutputPath>
20+
<DefineConstants>DEBUG;TRACE</DefineConstants>
21+
<ErrorReport>prompt</ErrorReport>
22+
<WarningLevel>4</WarningLevel>
23+
</PropertyGroup>
24+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
25+
<DebugType>pdbonly</DebugType>
26+
<Optimize>true</Optimize>
27+
<OutputPath>bin\Release\</OutputPath>
28+
<DefineConstants>TRACE</DefineConstants>
29+
<ErrorReport>prompt</ErrorReport>
30+
<WarningLevel>4</WarningLevel>
31+
</PropertyGroup>
32+
<ItemGroup>
33+
<Reference Include="System" />
34+
<Reference Include="System.Core" />
35+
<Reference Include="System.Xml.Linq" />
36+
<Reference Include="System.Data.DataSetExtensions" />
37+
<Reference Include="Microsoft.CSharp" />
38+
<Reference Include="System.Data" />
39+
<Reference Include="System.Xml" />
40+
</ItemGroup>
41+
<ItemGroup>
42+
<Compile Include="HttpEntry.cs" />
43+
<Compile Include="IHttpTrackingStore.cs" />
44+
<Compile Include="Properties\AssemblyInfo.cs" />
45+
</ItemGroup>
46+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
47+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
48+
Other similar extension points exist, see Microsoft.Common.targets.
49+
<Target Name="BeforeBuild">
50+
</Target>
51+
<Target Name="AfterBuild">
52+
</Target>
53+
-->
54+
</Project>

0 commit comments

Comments
 (0)