Fix bug parsing baseURL config

Change-Id: Ia8a5698ae5e0421672bd91f9a1c1497bcd36eb7c
This commit is contained in:
Aaron Boodman 2013-09-08 05:32:39 +00:00
parent acc90f184c
commit 97fab00c71
3 changed files with 125 additions and 3 deletions

View File

@ -560,14 +560,15 @@ func genLowLevelConfig(conf *Config) (lowLevelConf *Config, err error) {
}
if baseURL != "" {
obj["baseURL"] = strings.TrimSuffix(baseURL, "/")
u, err := url.Parse(baseURL)
if err != nil {
return nil, fmt.Errorf("Error parsing baseURL %q as a URL: %v", baseURL, err)
}
if u.Path != "/" {
return nil, errors.New("baseURL can't have a path, only a scheme, host, and optional port.")
if u.Path != "" && u.Path != "/" {
return nil, fmt.Errorf("baseURL can't have a path, only a scheme, host, and optional port.")
}
u.Path = ""
obj["baseURL"] = u.String()
}
if listen != "" {
obj["listen"] = listen

View File

@ -0,0 +1,110 @@
{
"listen": "localhost:3179",
"auth": "userpass:camlistore:pass3179",
"https": false,
"baseURL": "http://monkey.foo.com",
"prefixes": {
"/": {
"handler": "root",
"handlerArgs": {
"blobRoot": "/bs-and-maybe-also-index/",
"ownerName": "Alice",
"searchRoot": "/my-search/",
"statusRoot": "/status/",
"stealth": false
}
},
"/ui/": {
"handler": "ui",
"handlerArgs": {
"jsonSignRoot": "/sighelper/",
"cache": "/cache/",
"scaledImage": "lrucache"
}
},
"/setup/": {
"handler": "setup"
},
"/status/": {
"handler": "status"
},
"/share/": {
"handler": "share",
"handlerArgs": {
"blobRoot": "/bs/"
}
},
"/sync/": {
"handler": "sync",
"handlerArgs": {
"from": "/bs/",
"to": "/index-kv/"
}
},
"/sighelper/": {
"handler": "jsonsign",
"handlerArgs": {
"secretRing": "/path/to/secring",
"keyId": "26F5ABDA",
"publicKeyDest": "/bs-and-index/"
}
},
"/bs-and-index/": {
"handler": "storage-replica",
"handlerArgs": {
"backends": ["/bs/", "/index-kv/"]
}
},
"/bs-and-maybe-also-index/": {
"handler": "storage-cond",
"handlerArgs": {
"write": {
"if": "isSchema",
"then": "/bs-and-index/",
"else": "/bs/"
},
"read": "/bs/"
}
},
"/bs/": {
"handler": "storage-filesystem",
"handlerArgs": {
"path": "/tmp/blobs"
}
},
"/cache/": {
"handler": "storage-filesystem",
"handlerArgs": {
"path": "/tmp/blobs/cache"
}
},
"/index-kv/": {
"handler": "storage-kvfileindexer",
"handlerArgs": {
"blobSource": "/bs/",
"file": "/path/to/indexkv.db"
}
},
"/my-search/": {
"handler": "search",
"handlerArgs": {
"index": "/index-kv/",
"owner": "sha1-f2b0b7da718b97ce8c31591d8ed4645c777f3ef4"
}
}
}
}

11
pkg/serverconfig/testdata/baseurl.json vendored Normal file
View File

@ -0,0 +1,11 @@
{
"listen": "localhost:3179",
"auth": "userpass:camlistore:pass3179",
"baseURL": "http://monkey.foo.com",
"blobPath": "/tmp/blobs",
"kvIndexFile": "/path/to/indexkv.db",
"identity": "26F5ABDA",
"identitySecretRing": "/path/to/secring",
"ownerName": "Alice",
"shareHandlerPath": "/share/"
}