Mercurial > gemma
diff pkg/models/extservices.go @ 5601:1222b777f51f
Made golint finally happy.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Sat, 06 Aug 2022 02:09:57 +0200 |
parents | 5f47eeea988d |
children |
line wrap: on
line diff
--- a/pkg/models/extservices.go Sat Aug 06 00:46:21 2022 +0200 +++ b/pkg/models/extservices.go Sat Aug 06 02:09:57 2022 +0200 @@ -23,22 +23,27 @@ "gemma.intevation.de/gemma/pkg/log" ) +// ExtEntry is an external WFS service. type ExtEntry struct { Name string `json:"name"` URL string `json:"url"` WFS bool `json:"wfs"` } +// ExtServices is a list of the external services. type ExtServices struct { mu sync.Mutex entries []ExtEntry } +// ExternalServices is the list of external services +// the Gemma server manages as proxies. var ExternalServices = &ExtServices{} const selectExternalServices = `SELECT local_name, remote_url, is_wfs FROM sys_admin.external_services ORDER BY local_name` +// Find looks for a specific configures external service. func (es *ExtServices) Find(name string) (string, bool) { es.mu.Lock() defer es.mu.Unlock() @@ -84,16 +89,24 @@ }) } +// Invalidate invalidate the list of external services. func (es *ExtServices) Invalidate() { es.mu.Lock() es.entries = nil es.mu.Unlock() } -func ExternalAll(ExtEntry) bool { return true } +// ExternalAll passes all external entries as filter. +func ExternalAll(ExtEntry) bool { return true } + +// ExternalWMS passes only external entries which are not WFSs. func ExternalWMS(entry ExtEntry) bool { return !entry.WFS } + +// ExternalWFS passes only external enteries which are WFS. func ExternalWFS(entry ExtEntry) bool { return entry.WFS } +// Filter returns a list of external services which met +// the condition of the given accept filter. func (es *ExtServices) Filter(accept func(ExtEntry) bool) []ExtEntry { es.mu.Lock() defer es.mu.Unlock()