Mercurial > gemma
comparison cmd/wfs/dump.go @ 1624:943823d03d50
WFS downloader: Started with mapping return features to Go structs.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 18 Dec 2018 18:36:02 +0100 |
parents | 3093bab05c81 |
children | 92da44ba610c |
comparison
equal
deleted
inserted
replaced
1623:20c98c2964f7 | 1624:943823d03d50 |
---|---|
15 | 15 |
16 import ( | 16 import ( |
17 "bufio" | 17 "bufio" |
18 "fmt" | 18 "fmt" |
19 "io" | 19 "io" |
20 "net/http" | |
21 "os" | 20 "os" |
22 | 21 |
23 "gemma.intevation.de/gemma/pkg/wfs" | 22 "gemma.intevation.de/gemma/pkg/wfs" |
24 ) | 23 ) |
25 | 24 |
26 func dumpURL(out io.Writer, url string) error { | |
27 resp, err := http.Get(url) | |
28 if err != nil { | |
29 return err | |
30 } | |
31 defer resp.Body.Close() | |
32 _, err = io.Copy(out, resp.Body) | |
33 return err | |
34 } | |
35 | |
36 func dumpURLs(urls []string) error { | 25 func dumpURLs(urls []string) error { |
37 out := bufio.NewWriter(os.Stdout) | 26 out := bufio.NewWriter(os.Stdout) |
38 for _, url := range urls { | 27 if err := wfs.downloadURLs(urls, func(r io.Reader) error { |
39 if err := dumpURL(out, url); err != nil { | 28 _, err := io.Copy(out, r) |
40 return err | 29 return err |
41 } | 30 }); err != nil { |
31 return err | |
42 } | 32 } |
43 return out.Flush() | 33 return out.Flush() |
44 } | 34 } |
45 | 35 |
46 func dump(caps *wfs.Capabilities) { | 36 func dump(caps *wfs.Capabilities) { |