public function setModule($name, $module, $hook = 'after')
    {
        if (class_exists($module, true)) {
            switch ($hook) {
                case 'before':
                    $param = $this->request;
                    break;
                case 'after':
                    $param = $this->response;
                    break;
                default:
                    throw new \InvalidArgumentException("Invalid hook name!");
            }
            $this->registerModule($name, new $module($param), $hook);
        } else {
            throw new \OtherCode\Rest\Exceptions\ModuleNotFoundException('Module ' . $name . ' not found!');
        }
        return $this;
    }