Last active
October 29, 2015 11:27
-
-
Save milannankov/2202d2641c45f442667f to your computer and use it in GitHub Desktop.
Azure Mobile Services – Configuring The OWIN Pipeline
This file contains hidden or 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
public static class WebApiConfig | |
{ | |
public static void Register() | |
{ | |
var options = new ConfigOptions(); | |
// Create ConfigBuilder with another constructor | |
var builder = new ConfigBuilder(options, ConfigureDependencies); | |
var config = ServiceConfig.Initialize(builder); | |
Database.SetInitializer(new MobileServiceInitializer()); | |
} | |
private static void ConfigureDependencies(HttpConfiguration configuration, ContainerBuilder builder) | |
{ | |
// Configure DI here | |
// Register our extensions | |
builder.RegisterType<MyOwinAppBuilderExtension>().As<IOwinAppBuilderExtension>(); | |
builder.RegisterType<MyOwinAppBuilderExtension2>().As<IOwinAppBuilderExtension>(); | |
} | |
} |
This file contains hidden or 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
public class MyOwinAppBuilderExtension : IOwinAppBuilderExtension | |
{ | |
public void Configure(Owin.IAppBuilder appBuilder) | |
{ | |
appBuilder.UseMyAwesomeMiddleware(); | |
} | |
} |
This file contains hidden or 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
public static class WebApiConfig | |
{ | |
public static void Register() | |
{ | |
var options = new ConfigOptions(); | |
var config = ServiceConfig.Initialize(new ConfigBuilder(options)); | |
// Make sure this is after ServiceConfig.Initialize | |
// Otherwise ServiceConfig.Initialize will overwrite your changes | |
Microsoft.WindowsAzure.Mobile.Service.Config.StartupOwinAppBuilder.Initialize(appBuilder => | |
{ | |
//Configure OWIN here | |
appBuilder.UseFacebookAuthentication("", ""); | |
}); | |
Database.SetInitializer(new MobileServiceInitializer()); | |
} | |
} |
This file contains hidden or 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
public static class WebApiConfig | |
{ | |
public static void Register() | |
{ | |
var options = new ConfigOptions(); | |
// Create ConfigBuilder with another constructor | |
var builder = new ConfigBuilder(options, ConfigureDependencies); | |
var config = ServiceConfig.Initialize(builder); | |
Database.SetInitializer(new MobileServiceInitializer()); | |
} | |
private static void ConfigureDependencies(HttpConfiguration configuration, ContainerBuilder builder) | |
{ | |
// Configure DI here | |
// Register our custom builder | |
var instance = new MyCustomOwinAppBuilder(configuration); | |
builder.RegisterInstance(instance).As<IOwinAppBuilder>(); | |
} | |
} |
This file contains hidden or 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
public class MyCustomOwinAppBuilder : OwinAppBuilder | |
{ | |
public MyCustomOwinAppBuilder(HttpConfiguration config) | |
: base(config) | |
{ | |
} | |
public override void Configuration(IAppBuilder appBuilder) | |
{ | |
// Default configuration | |
base.Configuration(appBuilder); | |
// Custom configuration | |
appBuilder.UseMyAwesomeMiddleware(); | |
} | |
} |
This file contains hidden or 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
[assembly: OwinStartup(typeof(StartupOwinAppBuilder))] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment