This repository has been archived by the owner on Dec 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reintroduce NWebsec.Owin in Mvc.Server (aspnet50 only)
- Loading branch information
1 parent
7fac9f6
commit 0111029
Showing
3 changed files
with
70 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#if ASPNET50 | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNet.Builder; | ||
using Microsoft.AspNet.Hosting; | ||
using Microsoft.Owin.Builder; | ||
using Microsoft.Owin.BuilderProperties; | ||
using Owin; | ||
|
||
namespace Mvc.Server.Extensions { | ||
using AppFunc = Func<IDictionary<string, object>, Task>; | ||
using BuildFunc = Action<Func<Func<IDictionary<string, object>, Task>, | ||
Func<IDictionary<string, object>, Task>>>; | ||
|
||
public static class AppBuilderExtensions { | ||
public static void UseOwinAppBuilder(this IApplicationBuilder app, Action<IAppBuilder> configuration) { | ||
BuildFunc buildFunc = app.UseOwin(); | ||
|
||
buildFunc(next => { | ||
var builder = new AppBuilder(); | ||
var lifetime = (IApplicationLifetime) app.ApplicationServices.GetService(typeof(IApplicationLifetime)); | ||
var properties = new AppProperties(builder.Properties); | ||
properties.AppName = app.Server.Name; | ||
properties.OnAppDisposing = lifetime.ApplicationStopping; | ||
properties.DefaultApp = next; | ||
configuration(builder); | ||
AppFunc appFunc = (AppFunc) builder.Build(typeof(AppFunc)); | ||
return environment => appFunc.Invoke(environment); | ||
}); | ||
} | ||
} | ||
} | ||
#endif |
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