mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
* Moving app from singular to being created for every request. * Automatic refactor * Adding license header * Feedback fixes
65 lines
1.4 KiB
Go
65 lines
1.4 KiB
Go
// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
|
|
// See License.txt for license information.
|
|
|
|
package app
|
|
|
|
import (
|
|
"github.com/mattermost/mattermost-server/store"
|
|
)
|
|
|
|
type Option func(s *Server)
|
|
|
|
// By default, the app will use the store specified by the configuration. This allows you to
|
|
// construct an app with a different store.
|
|
//
|
|
// The override parameter must be either a store.Store or func(App) store.Store.
|
|
func StoreOverride(override interface{}) Option {
|
|
return func(s *Server) {
|
|
switch o := override.(type) {
|
|
case store.Store:
|
|
s.newStore = func() store.Store {
|
|
return o
|
|
}
|
|
case func(*Server) store.Store:
|
|
s.newStore = func() store.Store {
|
|
return o(s)
|
|
}
|
|
default:
|
|
panic("invalid StoreOverride")
|
|
}
|
|
}
|
|
}
|
|
|
|
func ConfigFile(file string) Option {
|
|
return func(s *Server) {
|
|
s.configFile = file
|
|
}
|
|
}
|
|
|
|
func DisableConfigWatch(s *Server) {
|
|
s.disableConfigWatch = true
|
|
}
|
|
|
|
type AppOption func(a *App)
|
|
type AppOptionCreator func() []AppOption
|
|
|
|
func ServerConnector(s *Server) AppOption {
|
|
return func(a *App) {
|
|
a.Srv = s
|
|
|
|
a.Log = s.Log
|
|
|
|
a.HTTPService = s.HTTPService
|
|
a.AccountMigration = s.AccountMigration
|
|
a.Cluster = s.Cluster
|
|
a.Compliance = s.Compliance
|
|
a.DataRetention = s.DataRetention
|
|
a.Elasticsearch = s.Elasticsearch
|
|
a.Ldap = s.Ldap
|
|
a.MessageExport = s.MessageExport
|
|
a.Metrics = s.Metrics
|
|
a.Mfa = s.Mfa
|
|
a.Saml = s.Saml
|
|
}
|
|
}
|