Skip to content

Instantly share code, notes, and snippets.

@dcomartin
Created December 7, 2017 03:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcomartin/81f09f24aeea004b831d96b0d49c3d90 to your computer and use it in GitHub Desktop.
Save dcomartin/81f09f24aeea004b831d96b0d49c3d90 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using Botwin;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
namespace BotwinDemo
{
public class Startup
{
// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
services.AddBotwin();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseBotwin();
}
}
public interface IBotwinRoutes
{
Dictionary<string,Type> GetRoutes();
}
public class MyRoutes : IBotwinRoutes
{
public Dictionary<string,Type> GetRoutes() => new Dictionary<string, Type>
{
{"/", typeof(MyModule)}
};
}
public class MyModule : BotwinModule
{
// Huzzah! I'm only constructed when one of my routes is actually called
public MyModule()
{
Get("/", async (ctx) =>
{
await ctx.Response.WriteAsync("Hello World!");
});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment