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

Side by Side Diff: logdog/server/service/rt.go

Issue 2643363002: LogDog: Use server/auth for authentication. (Closed)
Patch Set: LogDog: Use server/auth for authentication. Created 3 years, 11 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
« no previous file with comments | « logdog/server/cmd/logdog_collector/main.go ('k') | logdog/server/service/service.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 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 service
6
7 import (
8 "net/http"
9 "strings"
10
11 commonAuth "github.com/luci/luci-go/common/auth"
12 )
13
14 type serviceModifyingTransport struct {
15 userAgent string
16 }
17
18 func (smt *serviceModifyingTransport) roundTripper(base http.RoundTripper) http. RoundTripper {
19 if base == nil {
20 base = http.DefaultTransport
21 }
22
23 return commonAuth.NewModifyingTransport(base, func(req *http.Request) er ror {
24 // Set a user agent based on our service. If an existing user ag ent is
25 // specified, add it onto the end of the string.
26 parts := make([]string, 0, 2)
27 for _, part := range []string{
28 smt.userAgent,
29 req.UserAgent(),
30 } {
31 if part != "" {
32 parts = append(parts, part)
33 }
34 }
35 if len(parts) > 0 {
36 req.Header.Set("User-Agent", strings.Join(parts, " / "))
37 }
38 return nil
39 })
40 }
OLDNEW
« no previous file with comments | « logdog/server/cmd/logdog_collector/main.go ('k') | logdog/server/service/service.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698