messing around with the proxy mdh the proxy middleware

This commit is contained in:
Tom Gardham-Pallister
2016-07-21 20:28:22 +01:00
parent 5e8719cde4
commit dbff2b9530
15 changed files with 213 additions and 35 deletions

View File

@ -0,0 +1,34 @@
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
namespace Ocelot.AcceptanceTests.Fake
{
public class FakeService
{
private Task _handler;
private IWebHost _webHostBuilder;
public void Start(string url)
{
_webHostBuilder = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseUrls(url)
.UseStartup<FakeStartup>()
.Build();
_handler = Task.Run(() => _webHostBuilder.Run());
}
public void Stop()
{
if(_webHostBuilder != null)
{
_webHostBuilder.Dispose();
_handler.Wait();
}
}
}
}

View File

@ -0,0 +1,40 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
namespace Ocelot.AcceptanceTests.Fake
{
public class FakeStartup
{
public FakeStartup(IHostingEnvironment env)
{
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
.AddEnvironmentVariables();
Configuration = builder.Build();
}
public IConfigurationRoot Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
app.Run(async context =>
{
await context.Response.WriteAsync("Hello from Laura");
});
}
}
}