/// <summary> /// Initializes new instance of <see cref="Server"/>. /// </summary> /// <param name="url">The url to host the server on.</param> /// <param name="resolver">The dependency resolver for the server.</param> public Server(string url, IDependencyResolver resolver) : base(resolver) { _url = url.Replace("*", @".*?"); _listener = new HttpListener(); _listener.Prefixes.Add(url); _disconnectHandler = new DisconnectHandler(_listener); }
/// <summary> /// Initializes new instance of <see cref="Server"/>. /// </summary> /// <param name="url">The url to host the server on.</param> /// <param name="resolver">The dependency resolver for the server.</param> public Server(string url, IDependencyResolver resolver) : base(resolver) { _url = url.Replace("*", @".*?"); _listener = new HttpListener(); _listener.Prefixes.Add(url); _disconnectHandler = new DisconnectHandler(_listener); resolver.InitializePerformanceCounters(Process.GetCurrentProcess().GetUniqueInstanceName(_shutdownToken.Token), _shutdownToken.Token); }
/// <summary> /// Create an instance of <see cref="WebAppServer"/>. /// </summary> /// <param name="urlReservation"> /// The URL reservation to listen on. This string is similar to a URL, but the /// hostname may be a strong wildcard ('+') or a weak wildcard ('*'). E.g. "http://+:8080/". /// </param> public WebAppServer(string urlReservation) { _urlRegex = new Regex("^" + urlReservation.Replace("*", ".*?").Replace("+", ".*?"), RegexOptions.IgnoreCase); _listener = new HttpListener(); _listener.Prefixes.Add(urlReservation); _disconnectHandler = new DisconnectHandler(_listener); var uri = new Uri(urlReservation.Replace("*", "localhost").Replace("+", "localhost")); _webAppConfiguration = new WebAppConfiguration(uri); StaticFiles = new StaticFileSpecCollection(); }