| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 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 swarming | 5 package swarming |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "errors" | 8 "errors" |
| 9 "fmt" | 9 "fmt" |
| 10 "net/http" | 10 "net/http" |
| 11 "os" | 11 "os" |
| 12 | 12 |
| 13 "golang.org/x/net/context" | 13 "golang.org/x/net/context" |
| 14 "google.golang.org/api/googleapi" | 14 "google.golang.org/api/googleapi" |
| 15 | 15 |
| 16 "github.com/luci/luci-go/common/logging" | 16 "github.com/luci/luci-go/common/logging" |
| 17 » "github.com/luci/luci-go/milo/appengine/common" | 17 » "github.com/luci/luci-go/milo/common" |
| 18 "github.com/luci/luci-go/server/router" | 18 "github.com/luci/luci-go/server/router" |
| 19 "github.com/luci/luci-go/server/templates" | 19 "github.com/luci/luci-go/server/templates" |
| 20 ) | 20 ) |
| 21 | 21 |
| 22 var errUnrecognizedHost = errors.New("Unregistered Swarming Host") | 22 var errUnrecognizedHost = errors.New("Unregistered Swarming Host") |
| 23 | 23 |
| 24 // getSwarmingHost parses the swarming hostname out of the context. If | 24 // getSwarmingHost parses the swarming hostname out of the context. If |
| 25 // none is specified, get the default swarming host out of the global | 25 // none is specified, get the default swarming host out of the global |
| 26 // configs. | 26 // configs. |
| 27 func getSwarmingHost(c context.Context, r *http.Request) (string, error) { | 27 func getSwarmingHost(c context.Context, r *http.Request) (string, error) { |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 return http.StatusInternalServerError | 136 return http.StatusInternalServerError |
| 137 } | 137 } |
| 138 | 138 |
| 139 // isAPINotFound returns true if err is a HTTP 404 API response. | 139 // isAPINotFound returns true if err is a HTTP 404 API response. |
| 140 func isAPINotFound(err error) bool { | 140 func isAPINotFound(err error) bool { |
| 141 if apiErr, ok := err.(*googleapi.Error); ok && apiErr.Code == http.Statu
sNotFound { | 141 if apiErr, ok := err.(*googleapi.Error); ok && apiErr.Code == http.Statu
sNotFound { |
| 142 return true | 142 return true |
| 143 } | 143 } |
| 144 return false | 144 return false |
| 145 } | 145 } |
| OLD | NEW |