func NewServer(storages model.ServerStorageCollection, services model.ServerServices, restartChan chan<- bool) (model.Server, error) {
	if storages.Config == nil {
		return nil, fmt.Errorf("unable create sever with empty config storage")
	}
	settings, err := storages.Config.LoadServerSettings(false)
	if err != nil {
		return nil, err
	}
	s := Server{
		storages: storages,
		services: services,
		settings: settings,
	}
	hostName := os.Getenv("HOST_NAME")
	if len(hostName) == 0 {
		hostName = settings.General.Host
	}
	originChecker, err := middleware.NewAppOriginChecker(storages.App)
	if err != nil {
		return nil, err
	}
	routerSettings := web.RouterSetting{
		Server:           &s,
		ServeAdminPanel:  settings.AdminPanel.Enabled,
		HostName:         hostName,
		AppOriginChecker: originChecker,
		RestartChan:      restartChan,
		LoggerSettings:   settings.Logger,
	}
	r, err := web.NewRouter(routerSettings)
	if err != nil {
		return nil, err
	}
	s.MainRouter = r.(*web.Router)
	return &s, nil
}
NewServer creates backend service.
package server
import (
	"fmt"
	"net/http"
	"os"
	"github.com/madappgang/identifo/model"
	"github.com/madappgang/identifo/web"
	"github.com/madappgang/identifo/web/middleware"
)