@@ -23,71 +23,62 @@ public class MetricServer : BaseMetricServer, IMetricServer
2323 private readonly string _hostName ;
2424 private readonly int _port ;
2525 private readonly string _url ;
26- private readonly bool _useHttps ;
2726 private IWebHost _host ;
28-
29-
27+
3028 /// <summary>
3129 /// Constructor
3230 /// </summary>
3331 public MetricServer ( int port )
34- : this ( Consts . DefaultHost , port , Consts . DefaultUrl , null , null , null , false )
32+ : this ( Consts . DefaultHost , port , Consts . DefaultUrl , null , null , null )
3533 {
3634 }
3735
3836 /// <summary>
3937 /// Constructor
4038 /// </summary>
4139 public MetricServer ( string host , int port )
42- : this ( host , port , Consts . DefaultUrl , null , null , null , false )
40+ : this ( host , port , Consts . DefaultUrl , null , null , null )
4341 {
4442 }
4543
4644 /// <summary>
4745 /// Constructor
4846 /// </summary>
49- public MetricServer ( int port , X509Certificate2 certificate , bool useHttps )
50- : this ( Consts . DefaultHost , port , Consts . DefaultUrl , null , null , certificate , useHttps )
47+ public MetricServer ( int port , X509Certificate2 certificate )
48+ : this ( Consts . DefaultHost , port , Consts . DefaultUrl , null , null , certificate )
5149 {
5250 }
5351
5452 /// <summary>
5553 /// Constructor
5654 /// </summary>
57- public MetricServer ( string host , int port , X509Certificate2 certificate , bool useHttps )
58- : this ( host , port , Consts . DefaultUrl , null , null , certificate , useHttps )
55+ public MetricServer ( string host , int port , X509Certificate2 certificate )
56+ : this ( host , port , Consts . DefaultUrl , null , null , certificate )
5957 {
6058 }
6159
6260 /// <summary>
6361 /// Constructor
6462 /// </summary>
6563 public MetricServer ( string host , int port , string url , IEnumerable < IOnDemandCollector > standardCollectors , ICollectorRegistry registry )
66- : this ( host , port , url , standardCollectors , registry , null , false )
64+ : this ( host , port , url , standardCollectors , registry , null )
6765 {
6866 }
6967
7068
7169 /// <summary>
7270 /// Constructor
7371 /// </summary>
74- public MetricServer ( string host , int port , string url , IEnumerable < IOnDemandCollector > standardCollectors , ICollectorRegistry registry , X509Certificate2 certificate ,
75- bool useHttps )
72+ public MetricServer ( string host , int port , string url , IEnumerable < IOnDemandCollector > standardCollectors , ICollectorRegistry registry , X509Certificate2 certificate )
7673 : base ( standardCollectors , registry )
7774 {
78- if ( useHttps && certificate == null )
79- throw new ArgumentNullException ( nameof ( certificate ) , $ "{ nameof ( certificate ) } is required when using https") ;
80-
81- _useHttps = useHttps ;
8275 _certificate = certificate ;
8376 _port = port ;
8477 _hostName = host ;
8578 _url = url ;
8679 }
8780
88- /// <summary>
89- /// Server is Running?
90- /// </summary>
81+ /// <inheritdoc />
9182 public bool IsRunning => _host != null ;
9283
9384 /// <inheritdoc />
@@ -106,16 +97,16 @@ public void Start()
10697 . UseKestrel ( options =>
10798 {
10899#if NETSTANDARD13
109- if ( _useHttps )
100+ if ( _certificate != null )
110101 options . UseHttps ( _certificate ) ;
111102#endif
112103
113104#if NETSTANDARD20
114- if ( _useHttps )
105+ if ( _certificate != null )
115106 options . Listen ( IPAddress . Any , _port , listenOptions => { listenOptions . UseHttps ( _certificate ) ; } ) ;
116107#endif
117108 } )
118- . UseUrls ( $ "http{ ( _useHttps ? "s" : "" ) } ://{ _hostName } :{ _port } ")
109+ . UseUrls ( $ "http{ ( _certificate != null ? "s" : "" ) } ://{ _hostName } :{ _port } ")
119110 . ConfigureServices ( services => { services . AddSingleton < IStartup > ( new Startup ( Registry , _url ) ) ; } )
120111 . UseSetting ( WebHostDefaults . ApplicationKey , typeof ( Startup ) . GetTypeInfo ( ) . Assembly . FullName )
121112 . Build ( ) ;
0 commit comments