Exemple #1
0
 static void Main(string[] args)
 {
     try
     {
         Console.CancelKeyPress += Stop;
         using (var index = new EthIndex(true))
             using (var service = new RestService(index))
             {
                 index.ContinueRunning = () => ContinueRunning;
                 service.Run(() => ContinueRunning);
             }
     }
     catch (Exception e)
     {
         int level = 0;
         var oldE  = e;
         while (e != null)
         {
             var arrow = level == 0 ? "" : new String('-', level) + ">";
             Log.Error($"{arrow}{e.Message} ({e.GetType().Name})");
             level++;
             e = e.InnerException;
         }
         Log.Error(oldE.StackTrace);
     }
 }
Exemple #2
0
        public RestService(EthIndex index)
        {
            _index = index;
            _listener.Prefixes.Add($"http://*:{Configuration.Get().RestPort}/");
            _listener.Start();

            AddEndpoint("POST", "/api/history", HandleHistory);
            AddEndpoint("POST", "/api/gasprice", HandleGasPrice);

            foreach (var token in index.Tokens)
            {
                AddEndpoint("POST", $"/api/{token.Address}/history", (response, request, body) => HandleTokenHistory(token, response, request, body));
            }
        }