Add ability to specify chart generation url for self hosted QuickChart (#5)

* Add ability to specify chart generation url for self hosted QuickChart

* Add more configuration setting:

if user specify: a host only, default to https:443,
	         a host and http, set port to 80
	         a host and https, set port to 443

Co-authored-by: Duca Diana <dduca@globebmg.com>
This commit is contained in:
dianaduca 2022-03-12 02:11:32 +00:00 committed by GitHub
parent 32d5ada399
commit 03ac2f63d6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 62 additions and 4 deletions

View file

@ -31,7 +31,7 @@ namespace QuickChart
private static readonly HttpClient Client = new HttpClient();
public Chart()
public Chart(string scheme = null, string host = null, int? port = null)
{
Width = 500;
Height = 300;
@ -39,9 +39,40 @@ namespace QuickChart
Format = "png";
BackgroundColor = "transparent";
Scheme = "https";
Host = "quickchart.io";
Port = 443;
if (host != null)
{
Host = host;
if (scheme != null)
{
Scheme = scheme;
if (port.HasValue)
{
Port = port.Value;
}
else
{
if(scheme == "http")
{
Port = 80;
}
else
{
Port = 443;
}
}
}
else
{
Scheme = "https";
Port = 443;
}
}
else
{
Scheme = "https";
Host = "quickchart.io";
Port = 443;
}
}
public string GetUrl()