-
Notifications
You must be signed in to change notification settings - Fork 17
/
main.go
27 lines (23 loc) · 870 Bytes
/
main.go
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
package ecorest
import (
"github.com/OpenTreeMap/otm-ecoservice/ecorest/cache"
"github.com/OpenTreeMap/otm-ecoservice/ecorest/config"
"github.com/OpenTreeMap/otm-ecoservice/ecorest/endpoints"
"net/url"
)
type restManager struct {
ITreeCodesGET (func() *endpoints.ITreeCodes)
EcoGET (func(url.Values) (*endpoints.BenefitsWrapper, error))
EcoSummaryPOST (func(*endpoints.SummaryPostData) (*endpoints.BenefitsWrapper, error))
EcoScenarioPOST (func(*endpoints.ScenarioPostData) (*endpoints.Scenario, error))
InvalidateCacheGET (func())
}
func GetManager(cfg config.Config) *restManager {
ecoCache, invalidateCache := cache.Init(cfg)
invalidateCache()
return &restManager{endpoints.ITreeCodesGET(ecoCache),
endpoints.EcoGET(ecoCache),
endpoints.EcoSummaryPOST(ecoCache),
endpoints.EcoScenarioPOST(ecoCache),
invalidateCache}
}