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

Side by Side Diff: milo/buildsource/buildbucket/html.go

Issue 2977863002: [milo] Refactor all html knowledge out of backends. (Closed)
Patch Set: seems to work :) Created 3 years, 5 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 2016 The LUCI Authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 package buildbucket
16
17 import (
18 "errors"
19 "net/http"
20
21 "golang.org/x/net/context"
22
23 "github.com/julienschmidt/httprouter"
24 "github.com/luci/luci-go/milo/common"
25 "github.com/luci/luci-go/server/router"
26 "github.com/luci/luci-go/server/templates"
27 )
28
29 func parseBuilderQuery(c context.Context, r *http.Request, p httprouter.Params) (
30 query builderQuery, err error) {
31
32 query.Bucket = p.ByName("bucket")
33 if query.Bucket == "" {
34 err = errors.New("No bucket")
35 return
36 }
37
38 query.Builder = p.ByName("builder")
39 if query.Builder == "" {
40 err = errors.New("No builder")
41 return
42 }
43
44 // limit is a name of the query string parameter for specifying
45 // maximum number of builds to show.
46 query.Limit, err = common.GetLimit(r)
47 return
48 }
49
50 // BuilderHandler renders the builder view page.
51 // Note: The builder html template contains self links to "?limit=123", which co uld
52 // potentially override any other request parameters set.
53 func BuilderHandler(c *router.Context) {
54 query, err := parseBuilderQuery(c.Context, c.Request, c.Params)
55 if err != nil {
56 common.ErrorPage(c, http.StatusBadRequest, err.Error())
57 return
58 }
59
60 result, err := builderImpl(c.Context, query)
61 if err != nil {
62 common.ErrorPage(c, http.StatusInternalServerError, err.Error())
63 return
64 }
65
66 templates.MustRender(c.Context, c.Writer, "pages/builder.html", template s.Args{
67 "Builder": result,
68 })
69 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698