Mercurial > gemma
comparison cmd/wfs/dump.go @ 1619:3093bab05c81
WFS downloader: Dump features to stdout for testing purposes.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 18 Dec 2018 13:26:26 +0100 |
parents | 427f9010b4a9 |
children | 943823d03d50 |
comparison
equal
deleted
inserted
replaced
1618:9f5090fe130f | 1619:3093bab05c81 |
---|---|
12 // * Sascha L. Teichmann <sascha.teichmann@intevation.de> | 12 // * Sascha L. Teichmann <sascha.teichmann@intevation.de> |
13 | 13 |
14 package main | 14 package main |
15 | 15 |
16 import ( | 16 import ( |
17 "bufio" | |
17 "fmt" | 18 "fmt" |
19 "io" | |
20 "net/http" | |
21 "os" | |
18 | 22 |
19 "gemma.intevation.de/gemma/pkg/wfs" | 23 "gemma.intevation.de/gemma/pkg/wfs" |
20 ) | 24 ) |
25 | |
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 { | |
37 out := bufio.NewWriter(os.Stdout) | |
38 for _, url := range urls { | |
39 if err := dumpURL(out, url); err != nil { | |
40 return err | |
41 } | |
42 } | |
43 return out.Flush() | |
44 } | |
21 | 45 |
22 func dump(caps *wfs.Capabilities) { | 46 func dump(caps *wfs.Capabilities) { |
23 fmt.Println("service identification") | 47 fmt.Println("service identification") |
24 fmt.Println("----------------------") | 48 fmt.Println("----------------------") |
25 fmt.Printf("title: %s\n", caps.ServiceIdentification.Title) | 49 fmt.Printf("title: %s\n", caps.ServiceIdentification.Title) |