package baize import ( "git.sxidc.com/go-framework/baize/framework/core/api" "git.sxidc.com/go-framework/baize/framework/core/application" "git.sxidc.com/go-framework/baize/framework/core/infrastructure" ) func NewApplication(conf application.Config) *application.App { // 创建API apiConfig := conf.ApiConfig apiInstance := api.New(api.WithUrlPrefix(apiConfig.UrlPrefix), api.WithPort(apiConfig.Port), api.WithLogSkipPaths(apiConfig.LogSkipPaths...)) // 创建基础设施 infrastructureConfig := new(infrastructure.Config) infrastructureConfig.DatabaseConfig = conf.InfrastructureConfig.Database infrastructureConfig.CacheConfig = conf.InfrastructureConfig.Cache infrastructureInstance := infrastructure.NewInfrastructure(*infrastructureConfig) return application.New(apiInstance, infrastructureInstance) } func DestroyApplication(app *application.App) { if app == nil { return } infrastructure.DestroyInfrastructure(app.Infrastructure()) }