package com.kasije.core.impl.site;

import com.kasije.core.KasijeConfigRepo;
import com.kasije.core.WebSite;
import com.kasije.core.WebSiteRouter;
import com.kasije.core.config.Router;
import com.kasije.core.config.RouterConfig;
import org.apache.commons.lang.StringUtils;
import org.bridje.ioc.Component;
import org.bridje.ioc.Inject;
import org.bridje.ioc.Priority;

import java.io.IOException;

@Component
@Priority(value = Integer.MAX_VALUE)
public class WebSiteRouterImpl implements WebSiteRouter
{
    @Inject
    private KasijeConfigRepo configRepo;

    @Override
    public WebSite findWebSite(String serverName) throws IOException
    {
        RouterConfig config = configRepo.findConfig("./sites/", RouterConfig.class);

        Router router = config.getRouters().stream()
                .filter(r -> serverName.equals(r.getUri()))
                .findAny()
                .orElse(null);

        /* i try to resolved the location where it is hosting by configuration */

        if(null != router && StringUtils.isNotBlank(router.getPath()))
        {
            return new WebSiteImpl(router.getPath() + serverName);
        }

        /* by default in the current folder, into de sites */
        return new WebSiteImpl("./sites/" + serverName);
    }
}

@@ -636,24 +636,80 @@
 ption%0A    %7B%0A
+        /* the routerConfig.xml is into ./sites/etc/ */%0A
         Rout
@@ -950,24 +950,125 @@
 lse(null);%0A%0A
+         /* by default in the site is into de ./sites/ */%0A        String relativePath = %22./sites/%22;%0A%0A
         /* i
@@ -1137,17 +1137,16 @@
 tion */%0A
-%0A
         
@@ -1232,37 +1232,29 @@
       re
-turn new WebSiteImpl(
+lativePath = 
 router.g
@@ -1261,30 +1261,16 @@
 etPath()
- + serverName)
 ;%0A      
@@ -1278,70 +1278,8 @@
  %7D%0A%0A
-        /* by default in the current folder, into de sites */%0A
     
@@ -1305,26 +1305,28 @@
 iteImpl(
-%22./sites/%22
+relativePath
  + serve

Work over configuration router