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

Unified Diff: common/config/impl/remote/remote.go

Issue 2643803003: config: Update remote URL handling. (Closed)
Patch Set: Fix "nost" 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « common/config/impl/memory/memory.go ('k') | common/config/impl/remote/remote_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: common/config/impl/remote/remote.go
diff --git a/common/config/impl/remote/remote.go b/common/config/impl/remote/remote.go
index 2acdbdb83b2bfe5f507b9460f2013f68d2b805f2..7989512a31cc84b050919daea61f724c023c6ac8 100644
--- a/common/config/impl/remote/remote.go
+++ b/common/config/impl/remote/remote.go
@@ -34,24 +34,30 @@ type ClientFactory func(context.Context) (*http.Client, error)
// trippers are bound to contexts and carry RPC deadlines.
//
// If 'clients' is nil, http.DefaultClient will be used for all requests.
-func New(configServiceURL string, clients ClientFactory) config.Interface {
- serviceURL, err := url.Parse(configServiceURL)
- if err != nil {
- panic(fmt.Errorf("failed to parse service URL: %v", err))
- }
+func New(host string, insecure bool, clients ClientFactory) config.Interface {
if clients == nil {
clients = func(context.Context) (*http.Client, error) {
return http.DefaultClient, nil
}
}
+
+ serviceURL := url.URL{
+ Scheme: "https",
+ Host: host,
+ Path: "/_ah/api/config/v1/",
+ }
+ if insecure {
+ serviceURL.Scheme = "http"
+ }
+
return &remoteImpl{
- serviceURL: serviceURL,
+ serviceURL: serviceURL.String(),
clients: clients,
}
}
type remoteImpl struct {
- serviceURL *url.URL
+ serviceURL string
clients ClientFactory
}
@@ -67,12 +73,9 @@ func (r *remoteImpl) service(ctx context.Context) (*configApi.Service, error) {
if err != nil {
return nil, err
}
- service.BasePath = r.serviceURL.String()
- return service, nil
-}
-func (r *remoteImpl) ServiceURL(ctx context.Context) url.URL {
- return *r.serviceURL
+ service.BasePath = r.serviceURL
+ return service, nil
}
func (r *remoteImpl) GetConfig(ctx context.Context, configSet, path string, hashOnly bool) (*config.Config, error) {
« no previous file with comments | « common/config/impl/memory/memory.go ('k') | common/config/impl/remote/remote_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698