ice / framework

Source code of Ice framework
https://www.iceframework.org
BSD 3-Clause "New" or "Revised" License
341 stars 45 forks source link

Auto-dispatch subdomain to module #178

Open Yahasana opened 6 years ago

Yahasana commented 6 years ago

http://admin.example.com will auto route to and load admin module

mruz commented 6 years ago

How about if you set a default module to router:

$this->di->set('router', function () use ($request) {
    $router = new Router();

    switch ($request->getServer('HTTP_HOST')) {
        case 'admin.example.com':
            $router->setDefaultModule('admin');
            break;
        default:
            $router->setDefaultModule('front');
            break;
    }

    return $router;
});