public void TestNoDefault() { using var runner = TestRunner.Run(VirtualHosts.Create()); using var response = runner.GetRequest().GetSafeResponse(); Assert.Equal(HttpStatusCode.NotFound, response.StatusCode); }
public void TestDomains() { var hosts = VirtualHosts.Create() .Add("domain1.com", Layout.Create().Fallback(Content.From("domain1.com"))) .Add("domain2.com", Layout.Create().Fallback(Content.From("domain2.com"))) .Default(Layout.Create().Index(Content.From("default"))); using var runner = TestRunner.Run(hosts); TestHost(runner, "domain1.com"); TestHost(runner, "domain2.com"); TestHost(runner, "localhost", "default"); }
public static IHandlerBuilder Build(Environment environment, GatewayConfiguration config) { var hosts = VirtualHosts.Create(); if (config.Hosts != null) { foreach (var host in config.Hosts) { hosts.Add(host.Key, GetHandler(environment, host.Value)); } } return(hosts); }