Skip to content

Instantly share code, notes, and snippets.

@davidfowl
Last active August 21, 2018 22:05
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save davidfowl/86d8363f56892180885a54d871d9f95a to your computer and use it in GitHub Desktop.
Save davidfowl/86d8363f56892180885a54d871d9f95a to your computer and use it in GitHub Desktop.
Microservices
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
namespace WebApplication30
{
public class AppController : Controller
{
public virtual void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
Configure(app);
app.UseMvc();
}
protected virtual void Configure(IApplicationBuilder app)
{
}
}
}
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
namespace Microservice
{
public class Program : AppController
{
[HttpGet("/")]
public string Hello()
{
return "Hello World";
}
public static void Main(string[] args)
{
BuildWebHost(args).Run();
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Program>()
.Build();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment