summaryrefslogtreecommitdiffstats
path: root/app/app.go
blob: bf4a6b1b6dc81b22b7b01f22f78a2313e16d5a4c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

package app

import (
	"io/ioutil"
	"net/http"
	"sync"

	"github.com/mattermost/mattermost-server/einterfaces"
	"github.com/mattermost/mattermost-server/plugin/pluginenv"
)

type App struct {
	Srv *Server

	PluginEnv              *pluginenv.Environment
	PluginConfigListenerId string

	AccountMigration einterfaces.AccountMigrationInterface
	Brand            einterfaces.BrandInterface
	Cluster          einterfaces.ClusterInterface
	Compliance       einterfaces.ComplianceInterface
	Elasticsearch    einterfaces.ElasticsearchInterface
	Ldap             einterfaces.LdapInterface
	Metrics          einterfaces.MetricsInterface
	Mfa              einterfaces.MfaInterface
	Saml             einterfaces.SamlInterface
}

var globalApp App

var initEnterprise sync.Once

func Global() *App {
	initEnterprise.Do(func() {
		globalApp.AccountMigration = einterfaces.GetAccountMigrationInterface()
		globalApp.Brand = einterfaces.GetBrandInterface()
		globalApp.Cluster = einterfaces.GetClusterInterface()
		globalApp.Compliance = einterfaces.GetComplianceInterface()
		globalApp.Elasticsearch = einterfaces.GetElasticsearchInterface()
		globalApp.Ldap = einterfaces.GetLdapInterface()
		globalApp.Metrics = einterfaces.GetMetricsInterface()
		globalApp.Mfa = einterfaces.GetMfaInterface()
		globalApp.Saml = einterfaces.GetSamlInterface()
	})
	return &globalApp
}

func CloseBody(r *http.Response) {
	if r.Body != nil {
		ioutil.ReadAll(r.Body)
		r.Body.Close()
	}
}