Last active
November 19, 2018 23:53
-
-
Save jamesmundy/878a45cb829531157452e4209b234b4f to your computer and use it in GitHub Desktop.
An example WebAPIConfig file used to configure a bot framework web api.
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(HttpConfiguration config) | |
{ | |
var store = new TableBotDataStore(ConfigurationManager.ConnectionStrings["StorageConnectionString"] | |
.ConnectionString); | |
Conversation.UpdateContainer(builder => { | |
builder.RegisterModule(new DefaultExceptionMessageOverrideModule()); | |
builder.Register(c => store) | |
.Keyed<IBotDataStore<BotData>>(AzureModule.Key_DataStore) | |
.AsSelf() | |
.SingleInstance(); | |
builder.Register(c => new CachingBotDataStore(store, | |
.As<IBotDataStore<BotData>>() | |
.AsSelf() | |
.SingleInstance(); | |
// Register your Web API controllers. | |
builder.RegisterApiControllers(Assembly.GetExecutingAssembly()); | |
builder.RegisterWebApiFilterProvider(config); | |
}); | |
// Set the dependency resolver to be Autofac. | |
config.DependencyResolver = new AutofacWebApiDependencyResolver(Conversation.Container); | |
// Web API routes | |
config.MapHttpAttributeRoutes(); | |
config.Routes.MapHttpRoute("DefaultApi", | |
"api/{controller}/{id}", | |
new | |
{ | |
id = RouteParameter.Optional | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment