nitcorn: use a default virtual host when none are configure to handle a request
authorAlexis Laferrière <alexis.laf@xymus.net>
Fri, 8 Aug 2014 16:58:24 +0000 (12:58 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Wed, 10 Sep 2014 21:09:44 +0000 (17:09 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/nitcorn/reactor.nit
lib/nitcorn/server_config.nit

index a8f9236..0457f3c 100644 (file)
@@ -61,6 +61,9 @@ class HttpServer
                        end label
                end
 
+               # Use default virtual host if none already responded
+               if virtual_host == null then virtual_host = factory.config.default_virtual_host
+
                # Get a response from the virtual host
                var response
                if virtual_host != null then
index 2decb16..f90d4ef 100644 (file)
@@ -21,10 +21,11 @@ module server_config
 
 # Server instance configuration
 class ServerConfig
-       # Virtual hosts list
+       # `VirtualHost`s served by this server
        var virtual_hosts = new VirtualHosts(self)
 
-       # TODO implement serialization or something like that
+       # Default `VirtualHost` to respond to requests not handled by any of the `virtual_hosts`
+       var default_virtual_host: nullable VirtualHost = null
 end
 
 # A `VirtualHost` configuration