using System; using System.Collections.Generic; using System.Net.Http; using System.Web.Http; using System.Web.Http.Description; using ZeroLevel.Models; using ZeroLevel.Network; namespace ZeroLevel.Discovery { public class RoutesController : BaseController { [HttpGet] [Route("favicon.ico")] public HttpResponseMessage favicon(HttpRequestMessage request) { return null; } [HttpGet] [Route("api/v0/routes")] [ResponseType(typeof(IEnumerable))] public HttpResponseMessage GetRoutes(HttpRequestMessage request) { try { return request.CreateSelfDestroyingResponse(Injector.Default.Resolve().Get()); } catch (Exception ex) { Log.Error(ex, "Error with read records"); return BadRequestAnswer(request, ex); } } [HttpPost] [Route("api/v0/routes")] [ResponseType(typeof(InvokeResult))] public HttpResponseMessage AddRoute(HttpRequestMessage request, ExServiceInfo service) { try { var ir = Injector.Default.Resolve().Append(service); return request.CreateSelfDestroyingResponse(ir); } catch (Exception ex) { Log.Error(ex, "Error with append endpoint"); return BadRequestAnswer(request, ex); } } } }