Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: milo/appengine/common/utils.go

Issue 2748073006: Milo Refactor: Remove theme support (Closed)
Patch Set: Fix builder.html pointer Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file.
4
5 package common
6
7 import (
8 "fmt"
9 "net/http"
10 "strconv"
11 )
12
13 // GetLimit extracts the "limit", "numbuilds", or "num_builds" http param from
14 // the request, or returns "-1" implying no limit was specified.
15 func GetLimit(r *http.Request) (int, error) {
16 sLimit := r.FormValue("limit")
17 if sLimit == "" {
18 sLimit = r.FormValue("numbuilds")
19 if sLimit == "" {
20 sLimit = r.FormValue("num_builds")
21 if sLimit == "" {
22 return -1, nil
23 }
24 }
25 }
26 limit, err := strconv.Atoi(sLimit)
27 if err != nil {
28 return -1, fmt.Errorf("limit parameter value %q is not a number: %s", sLimit, err)
29 }
30 if limit < 0 {
31 return -1, fmt.Errorf("limit parameter value %q is less than 0", sLimit)
32 }
33 return limit, nil
34 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698