mirror of
https://github.com/ceph/ceph
synced 2025-01-03 09:32:43 +00:00
rgw: handle deep uri resources
In case of deep uri resources (ones created beyond a single level of hierarchy, e.g. auth/v1.0) we want to create a new empty handlers for the path if no handlers exists. E.g., for auth/v1.0 we need to have a handler for 'auth', otherwise the default S3 handler will be used, which we don't want. Signed-off-by: Yehuda Sadeh <yehuda@inktank.com> Reviewed-by: Greg Farnum <greg@inktank.com>
This commit is contained in:
parent
8d55b87f95
commit
ad3934e335
@ -1163,8 +1163,33 @@ void RGWRESTMgr::register_resource(string resource, RGWRESTMgr *mgr)
|
||||
{
|
||||
string r = "/";
|
||||
r.append(resource);
|
||||
|
||||
/* do we have a resource manager registered for this entry point? */
|
||||
map<string, RGWRESTMgr *>::iterator iter = resource_mgrs.find(r);
|
||||
if (iter != resource_mgrs.end()) {
|
||||
delete iter->second;
|
||||
}
|
||||
resource_mgrs[r] = mgr;
|
||||
resources_by_size.insert(pair<size_t, string>(r.size(), r));
|
||||
|
||||
/* now build default resource managers for the path (instead of nested entry points)
|
||||
* e.g., if the entry point is /auth/v1.0/ then we'd want to create a default
|
||||
* manager for /auth/
|
||||
*/
|
||||
|
||||
size_t pos = r.find('/', 1);
|
||||
|
||||
while (pos != r.size() - 1 && pos != string::npos) {
|
||||
string s = r.substr(0, pos);
|
||||
|
||||
iter = resource_mgrs.find(s);
|
||||
if (iter == resource_mgrs.end()) { /* only register it if one does not exist */
|
||||
resource_mgrs[s] = new RGWRESTMgr; /* a default do-nothing manager */
|
||||
resources_by_size.insert(pair<size_t, string>(s.size(), s));
|
||||
}
|
||||
|
||||
pos = r.find('/', pos + 1);
|
||||
}
|
||||
}
|
||||
|
||||
void RGWRESTMgr::register_default_mgr(RGWRESTMgr *mgr)
|
||||
|
Loading…
Reference in New Issue
Block a user