still hacking around

This commit is contained in:
Tom Gardham-Pallister
2017-02-17 07:27:49 +00:00
parent bc5010837e
commit 4dac8cb4fb
10 changed files with 250 additions and 16 deletions

View File

@ -0,0 +1,21 @@
using Microsoft.AspNetCore.Mvc;
using Ocelot.Services;
namespace Ocelot.Controllers
{
[RouteAttribute("configuration")]
public class FileConfigurationController
{
private IGetFileConfiguration _getFileConfig;
public FileConfigurationController(IGetFileConfiguration getFileConfig)
{
_getFileConfig = getFileConfig;
}
public IActionResult Get()
{
return new OkObjectResult(_getFileConfig.Invoke().Data);
}
}
}

View File

@ -1,13 +0,0 @@
using Microsoft.AspNetCore.Mvc;
namespace Ocelot.Controllers
{
[RouteAttribute("reroutes")]
public class ReRoutesController
{
public IActionResult Get()
{
return new OkObjectResult("hi from re routes controller");
}
}
}

View File

@ -0,0 +1,19 @@
using System;
using System.IO;
using Newtonsoft.Json;
using Ocelot.Configuration.File;
using Ocelot.Responses;
namespace Ocelot.Services
{
public class GetFileConfiguration : IGetFileConfiguration
{
public Response<FileConfiguration> Invoke()
{
var configFilePath = "configuration.json";
var json = File.ReadAllText(configFilePath);
var fileConfiguration = JsonConvert.DeserializeObject<FileConfiguration>(json);
return new OkResponse<FileConfiguration>(fileConfiguration);
}
}
}

View File

@ -0,0 +1,10 @@
using Ocelot.Configuration.File;
using Ocelot.Responses;
namespace Ocelot.Services
{
public interface IGetFileConfiguration
{
Response<FileConfiguration> Invoke();
}
}