| OLD | NEW |
| 1 // Copyright 2016 The LUCI Authors. All rights reserved. | 1 // Copyright 2016 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package logdog | 5 package logdog |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "net/http" | 8 "net/http" |
| 9 "strings" | 9 "strings" |
| 10 | 10 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 // temporarily (if incomplete) or indefinitely (if complete). | 29 // temporarily (if incomplete) or indefinitely (if complete). |
| 30 type AnnotationStreamHandler struct{} | 30 type AnnotationStreamHandler struct{} |
| 31 | 31 |
| 32 func BuildHandler(c *router.Context) { | 32 func BuildHandler(c *router.Context) { |
| 33 (&AnnotationStreamHandler{}).Render(c) | 33 (&AnnotationStreamHandler{}).Render(c) |
| 34 return | 34 return |
| 35 } | 35 } |
| 36 | 36 |
| 37 // Render implements settings.ThemedHandler. | 37 // Render implements settings.ThemedHandler. |
| 38 func (s *AnnotationStreamHandler) Render(c *router.Context) { | 38 func (s *AnnotationStreamHandler) Render(c *router.Context) { |
| 39 | |
| 40 as := AnnotationStream{ | 39 as := AnnotationStream{ |
| 41 Project: cfgtypes.ProjectName(c.Params.ByName("project")), | 40 Project: cfgtypes.ProjectName(c.Params.ByName("project")), |
| 42 Path: types.StreamPath(strings.Trim(c.Params.ByName("path"),
"/")), | 41 Path: types.StreamPath(strings.Trim(c.Params.ByName("path"),
"/")), |
| 43 } | 42 } |
| 44 if err := as.Normalize(); err != nil { | 43 if err := as.Normalize(); err != nil { |
| 45 common.ErrorPage(c, http.StatusBadRequest, err.Error()) | 44 common.ErrorPage(c, http.StatusBadRequest, err.Error()) |
| 46 return | 45 return |
| 47 } | 46 } |
| 48 | 47 |
| 49 // Setup our LogDog client. | 48 // Setup our LogDog client. |
| 50 var err error | 49 var err error |
| 51 » if as.Client, err = NewClient(c.Context, ""); err != nil { | 50 » host := strings.TrimSpace(c.Params.ByName("logdog_host")) |
| 51 » if as.Client, err = NewClient(c.Context, host); err != nil { |
| 52 log.WithError(err).Errorf(c.Context, "Failed to generate LogDog
client.") | 52 log.WithError(err).Errorf(c.Context, "Failed to generate LogDog
client.") |
| 53 common.ErrorPage(c, http.StatusInternalServerError, "Failed to g
enerate LogDog client") | 53 common.ErrorPage(c, http.StatusInternalServerError, "Failed to g
enerate LogDog client") |
| 54 return | 54 return |
| 55 } | 55 } |
| 56 | 56 |
| 57 // Load the Milo annotation protobuf from the annotation stream. | 57 // Load the Milo annotation protobuf from the annotation stream. |
| 58 if _, err := as.Fetch(c.Context); err != nil { | 58 if _, err := as.Fetch(c.Context); err != nil { |
| 59 switch errors.Unwrap(err) { | 59 switch errors.Unwrap(err) { |
| 60 case coordinator.ErrNoSuchStream: | 60 case coordinator.ErrNoSuchStream: |
| 61 common.ErrorPage(c, http.StatusNotFound, "Stream does no
t exist") | 61 common.ErrorPage(c, http.StatusNotFound, "Stream does no
t exist") |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 } | 108 } |
| 109 | 109 |
| 110 // Setup our LogDog client. | 110 // Setup our LogDog client. |
| 111 return coordinator.NewClient(&prpc.Client{ | 111 return coordinator.NewClient(&prpc.Client{ |
| 112 C: &http.Client{ | 112 C: &http.Client{ |
| 113 Transport: t, | 113 Transport: t, |
| 114 }, | 114 }, |
| 115 Host: host, | 115 Host: host, |
| 116 }), nil | 116 }), nil |
| 117 } | 117 } |
| OLD | NEW |