Merge lp:~sergiusens/snapweb/filterInstalled into lp:~snappy-dev/snapweb/trunk

Proposed by Sergio Schvezov
Status: Merged
Approved by: John Lenton
Approved revision: 128
Merged at revision: 127
Proposed branch: lp:~sergiusens/snapweb/filterInstalled
Merge into: lp:~snappy-dev/snapweb/trunk
Prerequisite: lp:~sergiusens/snapweb/originNamespacesInconsistencies
Diff against target: 52 lines (+16/-3)
2 files modified
snappy/converge.go (+2/-2)
snappy/handlers.go (+14/-1)
To merge this branch: bzr merge lp:~sergiusens/snapweb/filterInstalled
Reviewer Review Type Date Requested Status
Stephen Stewart (community) Approve
John Lenton (community) Approve
Review via email: mp+258440@code.launchpad.net

Commit message

Proper way to parametrize queries with gets

To post a comment you must log in.
Revision history for this message
John Lenton (chipaca) :
review: Approve
Revision history for this message
Stephen Stewart (stephen-stewart) wrote :

wfm

review: Approve
128. By Sergio Schvezov

Merged originNamespacesInconsistencies into filterInstalled.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'snappy/converge.go'
2--- snappy/converge.go 2015-05-07 15:42:24 +0000
3+++ snappy/converge.go 2015-05-07 15:42:24 +0000
4@@ -53,8 +53,8 @@
5 }
6
7 type listFilter struct {
8- Types []string `json:"types,omitempty"`
9- InstalledOnly bool `json:"installed_only"`
10+ Types []string
11+ InstalledOnly bool
12 }
13
14 // for easier stubbing during testing
15
16=== modified file 'snappy/handlers.go'
17--- snappy/handlers.go 2015-05-07 15:42:24 +0000
18+++ snappy/handlers.go 2015-05-07 15:42:24 +0000
19@@ -23,6 +23,7 @@
20 "io"
21 "log"
22 "net/http"
23+ "strings"
24
25 "launchpad.net/snappy/snappy"
26 "launchpad.net/webdm/webprogress"
27@@ -42,12 +43,24 @@
28 }
29 }
30
31+func installedOnly(v string) bool {
32+ return v == "true"
33+}
34+
35+func types(v string) []string {
36+ return strings.Split(v, ",")
37+}
38+
39 func (h *Handler) getAll(w http.ResponseWriter, r *http.Request) {
40 w.Header().Set("Content-Type", "application/json")
41 enc := json.NewEncoder(w)
42 dec := json.NewDecoder(r.Body)
43
44- var filter listFilter
45+ filter := listFilter{
46+ InstalledOnly: installedOnly(r.FormValue("installed_only")),
47+ Types: types(r.FormValue("types")),
48+ }
49+
50 if err := dec.Decode(&filter); err != nil && err != io.EOF {
51 w.WriteHeader(http.StatusInternalServerError)
52 enc.Encode(fmt.Sprintf("Error: %s", err))

Subscribers

People subscribed via source and target branches