code: func NewRouter(rootLogger *logrus.Logger, cfg config.Config, bridgeMap map[string]bridge.Factory) (*Router, error) {
  	logger := rootLogger.WithFields(logrus.Fields{"prefix": "router"})
  
  	r := &Router{
  		Config:           cfg,
  		BridgeMap:        bridgeMap,
  		Message:          make(chan config.Message),
  		MattermostPlugin: make(chan config.Message),
  		Gateways:         make(map[string]*Gateway),
  		logger:           logger,
  	}
  	sgw := samechannel.New(cfg)
  	gwconfigs := append(sgw.GetConfig(), cfg.BridgeValues().Gateway...)
  
  	for idx := range gwconfigs {
  		entry := &gwconfigs[idx]
  		if !entry.Enable {
  			continue
  		}
  		if entry.Name == "" {
  			return nil, fmt.Errorf("%s", "Gateway without name found")
  		}
  		if _, ok := r.Gateways[entry.Name]; ok {
  			return nil, fmt.Errorf("Gateway with name %s already exists", entry.Name)
  		}
  		r.Gateways[entry.Name] = New(rootLogger, entry, r)
  	}
  	return r, nil
  }
docs: // NewRouter initializes a new Matterbridge router for the specified configuration and
  // sets up all required gateways.