Skip to content

Commit e0c84be

Browse files
committed
Added OwinMiddleware Example
1 parent f8a455e commit e0c84be

12 files changed

+429
-0
lines changed

.gitignore

+182
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
## Ignore Visual Studio temporary files, build results, and
2+
## files generated by popular Visual Studio add-ons.
3+
4+
# User-specific files
5+
*.suo
6+
*.user
7+
*.sln.docstates
8+
9+
# Build results
10+
[Dd]ebug/
11+
[Dd]ebugPublic/
12+
[Rr]elease/
13+
[Rr]eleases/
14+
x64/
15+
x86/
16+
build/
17+
bld/
18+
[Bb]in/
19+
[Oo]bj/
20+
21+
# Roslyn cache directories
22+
*.ide/
23+
24+
# MSTest test Results
25+
[Tt]est[Rr]esult*/
26+
[Bb]uild[Ll]og.*
27+
28+
#NUNIT
29+
*.VisualState.xml
30+
TestResult.xml
31+
32+
# Build Results of an ATL Project
33+
[Dd]ebugPS/
34+
[Rr]eleasePS/
35+
dlldata.c
36+
37+
*_i.c
38+
*_p.c
39+
*_i.h
40+
*.ilk
41+
*.meta
42+
*.obj
43+
*.pch
44+
*.pdb
45+
*.pgc
46+
*.pgd
47+
*.rsp
48+
*.sbr
49+
*.tlb
50+
*.tli
51+
*.tlh
52+
*.tmp
53+
*.tmp_proj
54+
*.log
55+
*.vspscc
56+
*.vssscc
57+
.builds
58+
*.pidb
59+
*.svclog
60+
*.scc
61+
62+
# Chutzpah Test files
63+
_Chutzpah*
64+
65+
# Visual C++ cache files
66+
ipch/
67+
*.aps
68+
*.ncb
69+
*.opensdf
70+
*.sdf
71+
*.cachefile
72+
73+
# Visual Studio profiler
74+
*.psess
75+
*.vsp
76+
*.vspx
77+
78+
# TFS 2012 Local Workspace
79+
$tf/
80+
81+
# Guidance Automation Toolkit
82+
*.gpState
83+
84+
# ReSharper is a .NET coding add-in
85+
_ReSharper*/
86+
*.[Rr]e[Ss]harper
87+
*.DotSettings.user
88+
89+
# JustCode is a .NET coding addin-in
90+
.JustCode
91+
92+
# TeamCity is a build add-in
93+
_TeamCity*
94+
95+
# DotCover is a Code Coverage Tool
96+
*.dotCover
97+
98+
# NCrunch
99+
_NCrunch_*
100+
.*crunch*.local.xml
101+
102+
# MightyMoose
103+
*.mm.*
104+
AutoTest.Net/
105+
106+
# Web workbench (sass)
107+
.sass-cache/
108+
109+
# Installshield output folder
110+
[Ee]xpress/
111+
112+
# DocProject is a documentation generator add-in
113+
DocProject/buildhelp/
114+
DocProject/Help/*.HxT
115+
DocProject/Help/*.HxC
116+
DocProject/Help/*.hhc
117+
DocProject/Help/*.hhk
118+
DocProject/Help/*.hhp
119+
DocProject/Help/Html2
120+
DocProject/Help/html
121+
122+
# Click-Once directory
123+
publish/
124+
125+
# Publish Web Output
126+
*.[Pp]ublish.xml
127+
*.azurePubxml
128+
# TODO: Comment the next line if you want to checkin your web deploy settings
129+
# but database connection strings (with potential passwords) will be unencrypted
130+
*.pubxml
131+
*.publishproj
132+
133+
# NuGet Packages
134+
*.nupkg
135+
# The packages folder can be ignored because of Package Restore
136+
**/packages/*
137+
# except build/, which is used as an MSBuild target.
138+
!**/packages/build/
139+
# If using the old MSBuild-Integrated Package Restore, uncomment this:
140+
#!**/packages/repositories.config
141+
142+
# Windows Azure Build Output
143+
csx/
144+
*.build.csdef
145+
146+
# Windows Store app package directory
147+
AppPackages/
148+
149+
# Others
150+
sql/
151+
*.Cache
152+
ClientBin/
153+
[Ss]tyle[Cc]op.*
154+
~$*
155+
*~
156+
*.dbmdl
157+
*.dbproj.schemaview
158+
*.publishsettings
159+
node_modules/
160+
161+
# RIA/Silverlight projects
162+
Generated_Code/
163+
164+
# Backup & report files from converting an old project file
165+
# to a newer Visual Studio version. Backup files are not needed,
166+
# because we have git ;-)
167+
_UpgradeReport_Files/
168+
Backup*/
169+
UpgradeLog*.XML
170+
UpgradeLog*.htm
171+
172+
# SQL Server files
173+
*.mdf
174+
*.ldf
175+
176+
# Business Intelligence projects
177+
*.rdl.data
178+
*.bim.layout
179+
*.bim_*.settings
180+
181+
# Microsoft Fakes
182+
FakesAssemblies/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 2013
4+
VisualStudioVersion = 12.0.40629.0
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScottBrady91.BlogExampleCode.OwinMiddleware", "ScottBrady91.BlogExampleCode.OwinMiddleware\ScottBrady91.BlogExampleCode.OwinMiddleware.csproj", "{59B79A61-DFD9-4FD5-B405-AFCFF4F88D85}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{59B79A61-DFD9-4FD5-B405-AFCFF4F88D85}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{59B79A61-DFD9-4FD5-B405-AFCFF4F88D85}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{59B79A61-DFD9-4FD5-B405-AFCFF4F88D85}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{59B79A61-DFD9-4FD5-B405-AFCFF4F88D85}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace ScottBrady91.BlogExampleCode.OwinMiddleware.OwinMiddleware.Configuration
2+
{
3+
public sealed class TeapotOptions
4+
{
5+
public string Biscuit { get; set; }
6+
}
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
namespace ScottBrady91.BlogExampleCode.OwinMiddleware.OwinMiddleware.Handlers
2+
{
3+
using Owin;
4+
5+
using ScottBrady91.BlogExampleCode.OwinMiddleware.OwinMiddleware.Configuration;
6+
7+
internal static class TeapotMiddlewareHandler
8+
{
9+
public static IAppBuilder UseTeapotMiddleware(this IAppBuilder app, TeapotOptions options)
10+
{
11+
app.Use<TeapotMiddleware>(options);
12+
13+
return app;
14+
}
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
namespace ScottBrady91.BlogExampleCode.OwinMiddleware.OwinMiddleware
2+
{
3+
using System;
4+
using System.Threading.Tasks;
5+
6+
using Microsoft.Owin;
7+
8+
using ScottBrady91.BlogExampleCode.OwinMiddleware.OwinMiddleware.Configuration;
9+
10+
public sealed class TeapotMiddleware : OwinMiddleware
11+
{
12+
private readonly TeapotOptions options;
13+
14+
public TeapotMiddleware(OwinMiddleware next, TeapotOptions options)
15+
: base(next)
16+
{
17+
if (options == null)
18+
{
19+
throw new ArgumentNullException("options");
20+
}
21+
22+
this.options = options;
23+
}
24+
25+
public async override Task Invoke(IOwinContext context)
26+
{
27+
context.Response.Cookies.Append("Biscuit", this.options.Biscuit);
28+
context.Response.StatusCode = 418;
29+
// await this.Next.Invoke(context);
30+
}
31+
}
32+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System.Reflection;
2+
using System.Runtime.InteropServices;
3+
4+
[assembly: AssemblyTitle("ScottBrady91.BlogExampleCode.OwinMiddleware")]
5+
[assembly: AssemblyDescription("Example OwinMiddleware Implementation")]
6+
[assembly: AssemblyConfiguration("")]
7+
[assembly: AssemblyCompany("Scott Brady")]
8+
[assembly: AssemblyProduct("ScottBrady91.BlogExampleCode.OwinMiddleware")]
9+
[assembly: AssemblyCopyright("Copyright © Scott Brady 2015")]
10+
[assembly: AssemblyTrademark("")]
11+
[assembly: AssemblyCulture("")]
12+
[assembly: ComVisible(false)]
13+
[assembly: Guid("26872c02-ad6d-408b-a8d2-2f88d5edc395")]
14+
[assembly: AssemblyVersion("1.0.0.0")]
15+
[assembly: AssemblyFileVersion("1.0.0.0")]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
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+
<ProductVersion>
8+
</ProductVersion>
9+
<SchemaVersion>2.0</SchemaVersion>
10+
<ProjectGuid>{59B79A61-DFD9-4FD5-B405-AFCFF4F88D85}</ProjectGuid>
11+
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
12+
<OutputType>Library</OutputType>
13+
<AppDesignerFolder>Properties</AppDesignerFolder>
14+
<RootNamespace>ScottBrady91.BlogExampleCode.OwinMiddleware</RootNamespace>
15+
<AssemblyName>ScottBrady91.BlogExampleCode.OwinMiddleware</AssemblyName>
16+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
17+
<UseIISExpress>true</UseIISExpress>
18+
<IISExpressSSLPort />
19+
<IISExpressAnonymousAuthentication />
20+
<IISExpressWindowsAuthentication />
21+
<IISExpressUseClassicPipelineMode />
22+
</PropertyGroup>
23+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
24+
<DebugSymbols>true</DebugSymbols>
25+
<DebugType>full</DebugType>
26+
<Optimize>false</Optimize>
27+
<OutputPath>bin\</OutputPath>
28+
<DefineConstants>DEBUG;TRACE</DefineConstants>
29+
<ErrorReport>prompt</ErrorReport>
30+
<WarningLevel>4</WarningLevel>
31+
</PropertyGroup>
32+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
33+
<DebugType>pdbonly</DebugType>
34+
<Optimize>true</Optimize>
35+
<OutputPath>bin\</OutputPath>
36+
<DefineConstants>TRACE</DefineConstants>
37+
<ErrorReport>prompt</ErrorReport>
38+
<WarningLevel>4</WarningLevel>
39+
</PropertyGroup>
40+
<ItemGroup>
41+
<Reference Include="Microsoft.Owin, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
42+
<HintPath>..\packages\Microsoft.Owin.3.0.1\lib\net45\Microsoft.Owin.dll</HintPath>
43+
<Private>True</Private>
44+
</Reference>
45+
<Reference Include="Microsoft.Owin.Host.SystemWeb, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
46+
<HintPath>..\packages\Microsoft.Owin.Host.SystemWeb.3.0.1\lib\net45\Microsoft.Owin.Host.SystemWeb.dll</HintPath>
47+
<Private>True</Private>
48+
</Reference>
49+
<Reference Include="Owin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f0ebd12fd5e55cc5, processorArchitecture=MSIL">
50+
<HintPath>..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
51+
<Private>True</Private>
52+
</Reference>
53+
<Reference Include="System" />
54+
<Reference Include="System.Core" />
55+
</ItemGroup>
56+
<ItemGroup>
57+
<Content Include="packages.config" />
58+
<None Include="Web.Debug.config">
59+
<DependentUpon>Web.config</DependentUpon>
60+
</None>
61+
<None Include="Web.Release.config">
62+
<DependentUpon>Web.config</DependentUpon>
63+
</None>
64+
</ItemGroup>
65+
<ItemGroup>
66+
<Content Include="Web.config" />
67+
</ItemGroup>
68+
<ItemGroup>
69+
<Compile Include="OwinMiddleware\Configuration\TeapotOptions.cs" />
70+
<Compile Include="OwinMiddleware\Handlers\TeapotMiddlewareHandler.cs" />
71+
<Compile Include="OwinMiddleware\TeapotMiddleware.cs" />
72+
<Compile Include="Properties\AssemblyInfo.cs" />
73+
<Compile Include="Startup.cs" />
74+
</ItemGroup>
75+
<PropertyGroup>
76+
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
77+
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
78+
</PropertyGroup>
79+
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
80+
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
81+
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
82+
<ProjectExtensions>
83+
<VisualStudio>
84+
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
85+
<WebProjectProperties>
86+
<UseIIS>True</UseIIS>
87+
<AutoAssignPort>True</AutoAssignPort>
88+
<DevelopmentServerPort>8437</DevelopmentServerPort>
89+
<DevelopmentServerVPath>/</DevelopmentServerVPath>
90+
<IISUrl>http://localhost:8437/</IISUrl>
91+
<NTLMAuthentication>False</NTLMAuthentication>
92+
<UseCustomServer>False</UseCustomServer>
93+
<CustomServerUrl>
94+
</CustomServerUrl>
95+
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
96+
</WebProjectProperties>
97+
</FlavorProperties>
98+
</VisualStudio>
99+
</ProjectExtensions>
100+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
101+
Other similar extension points exist, see Microsoft.Common.targets.
102+
<Target Name="BeforeBuild">
103+
</Target>
104+
<Target Name="AfterBuild">
105+
</Target>
106+
-->
107+
</Project>

0 commit comments

Comments
 (0)