Commit 166f4ab9 authored by Jeremy Bokobza's avatar Jeremy Bokobza

Added api uri that can be passed by the cli

parent 049e63f6
...@@ -8,18 +8,18 @@ namespace Breeze.Api ...@@ -8,18 +8,18 @@ namespace Breeze.Api
{ {
public class Program public class Program
{ {
public static void Main(string[] args) public static void Main(string[] args)
{ {
Initialize(); }
}
public static void Initialize(IEnumerable<ServiceDescriptor> services = null, FullNode fullNode = null) public static void Initialize(IEnumerable<ServiceDescriptor> services, FullNode fullNode)
{ {
var host = new WebHostBuilder() var host = new WebHostBuilder()
.UseKestrel() .UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory()) .UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration() .UseIISIntegration()
.ConfigureServices(collection => .UseUrls(fullNode.Settings.ApiUri.ToString())
.ConfigureServices(collection =>
{ {
if (services == null || fullNode == null) if (services == null || fullNode == null)
{ {
......
cd ..
dotnet run light
\ No newline at end of file
cd..
dotnet run -testnet light
\ No newline at end of file
cd..
dotnet run light stratis
\ No newline at end of file
cd..
dotnet run -testnet light stratis addnode=13.64.76.48
\ No newline at end of file
...@@ -24,6 +24,9 @@ namespace Breeze.Daemon ...@@ -24,6 +24,9 @@ namespace Breeze.Daemon
{ {
public class Program public class Program
{ {
private const string DefaultBitcoinUri = "http://localhost:5000";
private const string DefaultStratisUri = "http://localhost:5105";
public static void Main(string[] args) public static void Main(string[] args)
{ {
IFullNodeBuilder fullNodeBuilder = null; IFullNodeBuilder fullNodeBuilder = null;
...@@ -31,13 +34,21 @@ namespace Breeze.Daemon ...@@ -31,13 +34,21 @@ namespace Breeze.Daemon
// configure logging // configure logging
Logs.Configure(Logs.GetLoggerFactory(args)); Logs.Configure(Logs.GetLoggerFactory(args));
// get the api uri
var apiUri = args.SingleOrDefault(arg => arg.StartsWith("apiuri"));
if (!string.IsNullOrEmpty(apiUri))
{
apiUri = apiUri.Replace("apiuri=", string.Empty);
}
if (args.Contains("stratis")) if (args.Contains("stratis"))
{ {
if (NodeSettings.PrintHelp(args, Network.StratisMain)) if (NodeSettings.PrintHelp(args, Network.StratisMain))
return; return;
var network = args.Contains("-testnet") ? InitStratisTest() : Network.StratisMain; var network = args.Contains("-testnet") ? InitStratisTest() : Network.StratisMain;
var nodeSettings = NodeSettings.FromArguments(args, "stratis", network, ProtocolVersion.ALT_PROTOCOL_VERSION); var nodeSettings = NodeSettings.FromArguments(args, "stratis", network, ProtocolVersion.ALT_PROTOCOL_VERSION);
nodeSettings.ApiUri = new Uri(string.IsNullOrEmpty(apiUri) ? DefaultStratisUri : apiUri);
if (args.Contains("light")) if (args.Contains("light"))
{ {
...@@ -63,6 +74,7 @@ namespace Breeze.Daemon ...@@ -63,6 +74,7 @@ namespace Breeze.Daemon
else else
{ {
NodeSettings nodeSettings = NodeSettings.FromArguments(args); NodeSettings nodeSettings = NodeSettings.FromArguments(args);
nodeSettings.ApiUri = new Uri(string.IsNullOrEmpty(apiUri) ? DefaultBitcoinUri : apiUri);
if (args.Contains("light")) if (args.Contains("light"))
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment