| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 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 buildbucket | |
| 6 | |
| 7 import ( | |
| 8 "errors" | |
| 9 "net/http" | |
| 10 | |
| 11 "golang.org/x/net/context" | |
| 12 | |
| 13 "github.com/julienschmidt/httprouter" | |
| 14 "github.com/luci/luci-go/milo/common" | |
| 15 "github.com/luci/luci-go/server/router" | |
| 16 "github.com/luci/luci-go/server/templates" | |
| 17 ) | |
| 18 | |
| 19 func parseBuilderQuery(c context.Context, r *http.Request, p httprouter.Params)
( | |
| 20 query builderQuery, err error) { | |
| 21 | |
| 22 query.Bucket = p.ByName("bucket") | |
| 23 if query.Bucket == "" { | |
| 24 err = errors.New("No bucket") | |
| 25 return | |
| 26 } | |
| 27 | |
| 28 query.Builder = p.ByName("builder") | |
| 29 if query.Builder == "" { | |
| 30 err = errors.New("No builder") | |
| 31 return | |
| 32 } | |
| 33 | |
| 34 // limit is a name of the query string parameter for specifying | |
| 35 // maximum number of builds to show. | |
| 36 query.Limit, err = common.GetLimit(r) | |
| 37 return | |
| 38 } | |
| 39 | |
| 40 // BuilderHandler renders the builder view page. | |
| 41 // Note: The builder html template contains self links to "?limit=123", which co
uld | |
| 42 // potentially override any other request parameters set. | |
| 43 func BuilderHandler(c *router.Context) { | |
| 44 query, err := parseBuilderQuery(c.Context, c.Request, c.Params) | |
| 45 if err != nil { | |
| 46 common.ErrorPage(c, http.StatusBadRequest, err.Error()) | |
| 47 return | |
| 48 } | |
| 49 | |
| 50 result, err := builderImpl(c.Context, query) | |
| 51 if err != nil { | |
| 52 common.ErrorPage(c, http.StatusInternalServerError, err.Error()) | |
| 53 return | |
| 54 } | |
| 55 | |
| 56 templates.MustRender(c.Context, c.Writer, "pages/builder.html", template
s.Args{ | |
| 57 "Builder": result, | |
| 58 }) | |
| 59 } | |
| OLD | NEW |