Chromium Code Reviews| Index: logdog/common/viewer/url.go |
| diff --git a/logdog/common/viewer/url.go b/logdog/common/viewer/url.go |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..eaece458ae213bfa35468cb42836855aec9dd21a |
| --- /dev/null |
| +++ b/logdog/common/viewer/url.go |
| @@ -0,0 +1,26 @@ |
| +// Copyright 2016 The LUCI Authors. All rights reserved. |
| +// Use of this source code is governed under the Apache License, Version 2.0 |
| +// that can be found in the LICENSE file. |
| + |
| +// Package viewer is a support library to interact with the LogDog web app and |
| +// log stream viewer. |
| +package viewer |
| + |
| +import ( |
| + "fmt" |
| + "net/url" |
| + "strings" |
| + |
| + "github.com/luci/luci-go/common/config" |
| + "github.com/luci/luci-go/logdog/common/types" |
| +) |
| + |
| +// GetURL generates a LogDog app viewer URL for the specified streams. |
| +func GetURL(host string, project config.ProjectName, paths ...types.StreamPath) string { |
| + pathQueries := make([]string, len(paths)) |
|
Vadim Sh.
2016/10/27 23:50:05
nit: use https://golang.org/pkg/net/url/#Values.Ad
dnj
2016/10/28 00:01:45
Oh shoot, I can't believe I forgot about this. Don
|
| + for i, p := range paths { |
| + pathQueries[i] = fmt.Sprintf("s=%s", url.QueryEscape(fmt.Sprintf("%s/%s", project, p))) |
| + } |
| + |
| + return fmt.Sprintf("https://%s/v/?%s", host, strings.Join(pathQueries, "&")) |
| +} |