]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: add support for dispatching requests with respect to frontend prefix.
authorRadoslaw Zarzynski <rzarzynski@mirantis.com>
Tue, 11 Oct 2016 14:07:21 +0000 (16:07 +0200)
committerRadoslaw Zarzynski <rzarzynski@mirantis.com>
Fri, 21 Oct 2016 20:57:22 +0000 (22:57 +0200)
Signed-off-by: Radoslaw Zarzynski <rzarzynski@mirantis.com>
23 files changed:
src/rgw/rgw_asio_frontend.cc
src/rgw/rgw_civetweb_frontend.cc
src/rgw/rgw_fcgi_process.cc
src/rgw/rgw_loadgen_process.cc
src/rgw/rgw_process.cc
src/rgw/rgw_process.h
src/rgw/rgw_rest.cc
src/rgw/rgw_rest.h
src/rgw/rgw_rest_bucket.h
src/rgw/rgw_rest_config.h
src/rgw/rgw_rest_log.h
src/rgw/rgw_rest_metadata.h
src/rgw/rgw_rest_opstate.h
src/rgw/rgw_rest_realm.cc
src/rgw/rgw_rest_realm.h
src/rgw/rgw_rest_replica_log.h
src/rgw/rgw_rest_s3.cc
src/rgw/rgw_rest_s3.h
src/rgw/rgw_rest_swift.cc
src/rgw/rgw_rest_swift.h
src/rgw/rgw_rest_usage.h
src/rgw/rgw_rest_user.h
src/rgw/rgw_swift_auth.h

index 0b8f436585c25777acbf7ff297b09ed1d1a23e8e..b785e7b07b7a59669ee0e210f90c2c6b592b15d2 100644 (file)
@@ -99,7 +99,8 @@ class AsioConnection : public std::enable_shared_from_this<AsioConnection> {
                                 rgw::io::add_conlen_controlling(
                                   &real_client))));
     RGWRestfulIO client(&real_client_io);
-    process_request(env.store, env.rest, &req, &client, env.olog);
+    process_request(env.store, env.rest, &req, env.uri_prefix, &client,
+                    env.olog);
   }
 
   void write_bad_request() {
index cda10f027fbe580965b9b617a5adf5c6170bc817..e0adeb8040f69ac6b8d17cb1a43156d2c9339928 100644 (file)
@@ -30,7 +30,8 @@ int RGWCivetWebFrontend::process(struct mg_connection*  const conn)
                                 RGWCivetWeb(conn, env.port)))));
   RGWRestfulIO client_io(&real_client_io);
 
-  int ret = process_request(env.store, env.rest, &req, &client_io, env.olog);
+  int ret = process_request(env.store, env.rest, &req, env.uri_prefix,
+                            &client_io, env.olog);
   if (ret < 0) {
     /* We don't really care about return code. */
     dout(20) << "process_request() returned " << ret << dendl;
index 20bb3e2b0b0f4be3c55fd6621fc5e4301ef754eb..5dffbfb0f8c2f376d69bdc70a74630f8fe892b3b 100644 (file)
@@ -123,7 +123,7 @@ void RGWFCGXProcess::handle_request(RGWRequest* r)
   RGWRestfulIO client_io(&real_client_io);
 
  
-  int ret = process_request(store, rest, req, &client_io, olog);
+  int ret = process_request(store, rest, req, uri_prefix, &client_io, olog);
   if (ret < 0) {
     /* we don't really care about return code */
     dout(20) << "process_request() returned " << ret << dendl;
index d857d6c540e7811b65a53f3670e1476b67df6bd2..62a4ebd52bcb438112547f21ae6ad2a48aedd538 100644 (file)
@@ -131,7 +131,7 @@ void RGWLoadGenProcess::handle_request(RGWRequest* r)
   RGWLoadGenIO real_client_io(&env);
   RGWRestfulIO client_io(&real_client_io);
 
-  int ret = process_request(store, rest, req, &client_io, olog);
+  int ret = process_request(store, rest, req, uri_prefix, &client_io, olog);
   if (ret < 0) {
     /* we don't really care about return code */
     dout(20) << "process_request() returned " << ret << dendl;
index 08c8ce01e153442eb75dc1bfffd391a3ff7a6af5..55c390aae58f586712a4aa454a45aee90965cc89 100644 (file)
@@ -109,8 +109,12 @@ int rgw_process_authenticated(RGWHandler_REST * const handler,
   return 0;
 }
 
-int process_request(RGWRados* store, RGWREST* rest, RGWRequest* req,
-                   RGWRestfulIO* client_io, OpsLogSocket* olog)
+int process_request(RGWRados* const store,
+                    RGWREST* const rest,
+                    RGWRequest* const req,
+                    const std::string& frontend_prefix,
+                    RGWRestfulIO* const client_io,
+                    OpsLogSocket* const olog)
 {
   int ret = 0;
 
@@ -142,8 +146,8 @@ int process_request(RGWRados* store, RGWREST* rest, RGWRequest* req,
   int init_error = 0;
   bool should_log = false;
   RGWRESTMgr *mgr;
-  RGWHandler_REST *handler = rest->get_handler(store, s, client_io, &mgr,
-                                             &init_error);
+  RGWHandler_REST *handler = rest->get_handler(store, s, frontend_prefix,
+                                               client_io, &mgr, &init_error);
   if (init_error != 0) {
     abort_early(s, NULL, init_error, NULL);
     goto done;
index 8e3c71af4420471a59b00a9e3830819225e4769d..eed49b80551665ff90a32f5ce74bf1db6ffe628f 100644 (file)
@@ -45,6 +45,7 @@ protected:
   RGWREST* rest;
   RGWFrontendConfig* conf;
   int sock_fd;
+  std::string uri_prefix;
 
   struct RGWWQ : public ThreadPool::WorkQueue<RGWRequest> {
     RGWProcess* process;
@@ -96,16 +97,24 @@ protected:
   } req_wq;
 
 public:
-  RGWProcess(CephContext* cct, RGWProcessEnv* pe, int num_threads,
-           RGWFrontendConfig* _conf)
-    : cct(cct), store(pe->store), olog(pe->olog),
+  RGWProcess(CephContext* const cct,
+             RGWProcessEnv* const pe,
+             const int num_threads,
+             RGWFrontendConfig* const conf)
+    : cct(cct),
+      store(pe->store),
+      olog(pe->olog),
       m_tp(cct, "RGWProcess::m_tp", "tp_rgw_process", num_threads),
       req_throttle(cct, "rgw_ops", num_threads * 2),
-      rest(pe->rest), conf(_conf), sock_fd(-1),
+      rest(pe->rest),
+      conf(conf),
+      sock_fd(-1),
+      uri_prefix(pe->uri_prefix),
       req_wq(this, g_conf->rgw_op_thread_timeout,
-            g_conf->rgw_op_thread_suicide_timeout, &m_tp) {}
+            g_conf->rgw_op_thread_suicide_timeout, &m_tp) {
+  }
   
-  virtual ~RGWProcess() {}
+  virtual ~RGWProcess() = default;
 
   virtual void run() = 0;
   virtual void handle_request(RGWRequest *req) = 0;
@@ -129,7 +138,6 @@ public:
 
 class RGWFCGXProcess : public RGWProcess {
   int max_connections;
-  std::string uri_prefix;
 public:
 
   /* have a bit more connections than threads so that requests are
@@ -137,12 +145,10 @@ public:
   RGWFCGXProcess(CephContext* const cct,
                  RGWProcessEnv* const pe,
                  const int num_threads,
-                 RGWFrontendConfig* const _conf)
-    : RGWProcess(cct, pe, num_threads, _conf),
-      max_connections(num_threads + (num_threads >> 3)),
-      /* We shouldn't mess with our parents by std::moving here. */
-      uri_prefix(pe->uri_prefix)
-    {}
+                 RGWFrontendConfig* const conf)
+    : RGWProcess(cct, pe, num_threads, conf),
+      max_connections(num_threads + (num_threads >> 3)) {
+  }
 
   void run();
   void handle_request(RGWRequest* req);
@@ -178,7 +184,8 @@ public:
 extern int process_request(RGWRados* store,
                            RGWREST* rest,
                            RGWRequest* req,
-                          RGWRestfulIO* client_io,
+                           const std::string& frontend_prefix,
+                           RGWRestfulIO* client_io,
                            OpsLogSocket* olog);
 
 extern int rgw_process_authenticated(RGWHandler_REST* handler,
index d22ee87c4f88753a7fea6cac50cbc60c412897b3..23ac325566bdcb108fbc0677b6a2928556bb9214 100644 (file)
@@ -1748,7 +1748,9 @@ void RGWRESTMgr::register_default_mgr(RGWRESTMgr *mgr)
   default_mgr = mgr;
 }
 
-RGWRESTMgr *RGWRESTMgr::get_resource_mgr(struct req_state *s, const string& uri, string *out_uri)
+RGWRESTMgr* RGWRESTMgr::get_resource_mgr(struct req_state* const s,
+                                         const std::string& uri,
+                                         std::string* const out_uri)
 {
   *out_uri = uri;
 
@@ -1759,7 +1761,7 @@ RGWRESTMgr *RGWRESTMgr::get_resource_mgr(struct req_state *s, const string& uri,
     if (uri.compare(0, iter->first, resource) == 0 &&
        (uri.size() == iter->first ||
         uri[iter->first] == '/')) {
-      string suffix = uri.substr(iter->first);
+      std::string suffix = uri.substr(iter->first);
       return resource_mgrs[resource]->get_resource_mgr(s, suffix, out_uri);
     }
   }
@@ -2042,34 +2044,38 @@ int RGWREST::preprocess(struct req_state *s, rgw::io::BasicClient* cio)
   return 0;
 }
 
-RGWHandler_REST* RGWREST::get_handler(RGWRados *store, struct req_state *s,
-                                     RGWRestfulIO *rio, RGWRESTMgr **pmgr,
-                                     int *init_error)
+RGWHandler_REST* RGWREST::get_handler(RGWRados * const store,
+                                      struct req_state* const s,
+                                      const std::string& frontend_prefix,
+                                      RGWRestfulIO* const rio,
+                                      RGWRESTMgr** const pmgr,
+                                      int* const init_error)
 {
-  RGWHandler_REST* handler;
-
   *init_error = preprocess(s, rio);
-  if (*init_error < 0)
-    return NULL;
+  if (*init_error < 0) {
+    return nullptr;
+  }
 
-  RGWRESTMgr *m = mgr.get_resource_mgr(s, s->decoded_uri, &s->relative_uri);
-  if (!m) {
+  RGWRESTMgr *m = mgr.get_manager(s, frontend_prefix, s->decoded_uri,
+                                  &s->relative_uri);
+  if (! m) {
     *init_error = -ERR_METHOD_NOT_ALLOWED;
-    return NULL;
+    return nullptr;
   }
 
-  if (pmgr)
+  if (pmgr) {
     *pmgr = m;
+  }
 
-  handler = m->get_handler(s);
-  if (!handler) {
+  RGWHandler_REST* handler = m->get_handler(s, frontend_prefix);
+  if (! handler) {
     *init_error = -ERR_METHOD_NOT_ALLOWED;
     return NULL;
   }
   *init_error = handler->init(store, s, rio);
   if (*init_error < 0) {
     m->put_handler(handler);
-    return NULL;
+    return nullptr;
   }
 
   return handler;
index 32c7fdbee408c2d460af9c0b36f87c3cb6497e51..ec178d246d87a11e8e4a5f98f2ffd33a503c1f62 100644 (file)
@@ -444,6 +444,16 @@ protected:
   std::multimap<size_t, std::string> resources_by_size;
   RGWRESTMgr* default_mgr;
 
+  virtual RGWRESTMgr* get_resource_mgr(struct req_state* s,
+                                       const std::string& uri,
+                                       std::string* out_uri);
+
+  virtual RGWRESTMgr* get_resource_mgr_as_default(struct req_state* const s,
+                                                  const std::string& uri,
+                                                  std::string* our_uri) {
+    return this;
+  }
+
 public:
   RGWRESTMgr()
     : should_log(false),
@@ -451,24 +461,34 @@ public:
   }
   virtual ~RGWRESTMgr();
 
-  void register_resource(string resource, RGWRESTMgr *mgr);
-  void register_default_mgr(RGWRESTMgr *mgr);
+  void register_resource(std::string resource, RGWRESTMgr* mgr);
+  void register_default_mgr(RGWRESTMgrmgr);
 
-  virtual RGWRESTMgr* get_resource_mgr(struct req_state *s,
-                                       const std::string& uri,
-                                       std::string* out_uri);
+  virtual RGWRESTMgr* get_manager(struct req_state* const s,
+                                  /* Prefix to be concatenated with @uri
+                                   * during the lookup. */
+                                  const std::string& frontend_prefix,
+                                  const std::string& uri,
+                                  std::string* out_uri) final {
+    return get_resource_mgr(s, frontend_prefix + uri, out_uri);
+  }
 
-  virtual RGWRESTMgr* get_resource_mgr_as_default(struct req_state* s,
-                                                  const std::string& uri,
-                                                  std::string* our_uri) {
-    return this;
+  virtual RGWHandler_REST* get_handler(struct req_state* const s,
+                                       const std::string& frontend_prefix) {
+    return nullptr;
   }
 
-  virtual RGWHandler_REST *get_handler(struct req_state *s) { return NULL; }
-  virtual void put_handler(RGWHandler_REST *handler) { delete handler; }
+  virtual void put_handler(RGWHandler_REST* const handler) {
+    delete handler;
+  }
+
+  void set_logging(bool _should_log) {
+    should_log = _should_log;
+  }
 
-  void set_logging(bool _should_log) { should_log = _should_log; }
-  bool get_logging() { return should_log; }
+  bool get_logging() const {
+    return should_log;
+  }
 };
 
 class RGWLibIO;
@@ -482,6 +502,7 @@ public:
   RGWREST() {}
   RGWHandler_REST *get_handler(RGWRados *store,
                                struct req_state *s,
+                               const std::string& frontend_prefix,
                                RGWRestfulIO *rio,
                                RGWRESTMgr **pmgr,
                                int *init_error);
index 227ef914d3af3bff19c9b24cc35d0a76e1c410c3..547bc9e7a9b381261b0557d7553d9a835daab0db 100644 (file)
@@ -25,10 +25,11 @@ public:
 
 class RGWRESTMgr_Bucket : public RGWRESTMgr {
 public:
-  RGWRESTMgr_Bucket() {}
-  virtual ~RGWRESTMgr_Bucket() {}
+  RGWRESTMgr_Bucket() = default;
+  virtual ~RGWRESTMgr_Bucket() = default;
 
-  RGWHandler_REST* get_handler(struct req_state *s) {
+  RGWHandler_REST* get_handler(struct req_state*,
+                               const std::string&) override {
     return new RGWHandler_Bucket;
   }
 };
index fe7f0272b0c29fb17d46860d0887da2e43ce183f..e9fcfd79ca6c9c7835d9d077bafc09a8b9bb610f 100644 (file)
@@ -51,10 +51,11 @@ public:
 
 class RGWRESTMgr_Config : public RGWRESTMgr {
 public:
-  RGWRESTMgr_Config() {}
-  virtual ~RGWRESTMgr_Config() {}
+  RGWRESTMgr_Config() = default;
+  virtual ~RGWRESTMgr_Config() = default;
 
-  virtual RGWHandler_REST* get_handler(struct req_state *s){
+  RGWHandler_REST* get_handler(struct req_state*,
+                               const std::string&) override {
     return new RGWHandler_Config;
   }
 };
index c5e94f6232eaa7151afeefd2dc7497185dcdbce8..cf972a02d4d65e0f774b9b64828a5d60e117c177 100644 (file)
@@ -321,10 +321,11 @@ public:
 
 class RGWRESTMgr_Log : public RGWRESTMgr {
 public:
-  RGWRESTMgr_Log() {}
-  virtual ~RGWRESTMgr_Log() {}
+  RGWRESTMgr_Log() = default;
+  virtual ~RGWRESTMgr_Log() = default;
 
-  virtual RGWHandler_REST* get_handler(struct req_state *s){
+  RGWHandler_REST* get_handler(struct req_state* const,
+                               const std::string& frontend_prefixs) override {
     return new RGWHandler_Log;
   }
 };
index 2511b9bfa6208a2274ecc1809962f4afba984c49..d0272f4b2b74b133b92eeae6f429dd5134ed10b5 100644 (file)
@@ -113,10 +113,11 @@ public:
 
 class RGWRESTMgr_Metadata : public RGWRESTMgr {
 public:
-  RGWRESTMgr_Metadata() {}
-  virtual ~RGWRESTMgr_Metadata() {}
+  RGWRESTMgr_Metadata() = default;
+  virtual ~RGWRESTMgr_Metadata() = default;
 
-  virtual RGWHandler_REST* get_handler(struct req_state *s){
+  RGWHandler_REST* get_handler(struct req_state* const s,
+                               const std::string& frontend_prefix) override {
     return new RGWHandler_Metadata;
   }
 };
index 1a8076c6876292139cb9f3105af6b8c872d0255e..632ef26c2e1bbbbffcee245010f352a0ef8e20c6 100644 (file)
@@ -98,10 +98,11 @@ public:
 
 class RGWRESTMgr_Opstate : public RGWRESTMgr {
 public:
-  RGWRESTMgr_Opstate() {}
-  virtual ~RGWRESTMgr_Opstate() {}
+  RGWRESTMgr_Opstate() = default;
+  virtual ~RGWRESTMgr_Opstate() = default;
 
-  virtual RGWHandler_REST* get_handler(struct req_state *s){
+  RGWHandler_REST* get_handler(struct req_state*,
+                               const std::string&) override {
     return new RGWHandler_Opstate;
   }
 };
index 008ab10d633baa97b50e465d516b7ce5f1029a88..99fd60b1d06f9309cb3c98a25975849a6786844f 100644 (file)
@@ -228,7 +228,8 @@ class RGWHandler_Period : public RGWHandler_Auth_S3 {
 
 class RGWRESTMgr_Period : public RGWRESTMgr {
  public:
-  RGWHandler_REST* get_handler(struct req_state*) override {
+  RGWHandler_REST* get_handler(struct req_state*,
+                               const std::string&) override {
     return new RGWHandler_Period;
   }
 };
@@ -285,7 +286,8 @@ RGWRESTMgr_Realm::RGWRESTMgr_Realm()
   register_resource("period", new RGWRESTMgr_Period);
 }
 
-RGWHandler_REST* RGWRESTMgr_Realm::get_handler(struct req_state*)
+RGWHandler_REST* RGWRESTMgr_Realm::get_handler(struct req_state*,
+                                               const std::string&)
 {
   return new RGWHandler_Realm;
 }
index cb61594595d8ee0a4079fae2aacf78622190df68..6d554949556d3bcb52da21da0563ec937f8cd0eb 100644 (file)
@@ -10,7 +10,8 @@ class RGWRESTMgr_Realm : public RGWRESTMgr {
 public:
   RGWRESTMgr_Realm();
 
-  RGWHandler_REST* get_handler(struct req_state*) override;
+  RGWHandler_REST* get_handler(struct req_state*,
+                               const std::string&) override;
 };
 
 #endif
index 76ccc3fcb7caee4b45d677ccd4cf214645aaeccd..a264cb7986e9b441e3de6a6f26867660ccf90f6b 100644 (file)
@@ -144,10 +144,11 @@ public:
 
 class RGWRESTMgr_ReplicaLog : public RGWRESTMgr {
 public:
-  RGWRESTMgr_ReplicaLog() {}
-  virtual ~RGWRESTMgr_ReplicaLog() {}
+  RGWRESTMgr_ReplicaLog() = default;
+  virtual ~RGWRESTMgr_ReplicaLog() = default;
 
-  virtual RGWHandler_REST* get_handler(struct req_state *s){
+  RGWHandler_REST* get_handler(struct req_state*,
+                               const std::string&) override {
     return new RGWHandler_ReplicaLog;
   }
 };
index 7f4f3c22d2cf0ca729549e736477830fd3f4e6ed..00ed83b3582ffdbf431461626421009fd98c479b 100644 (file)
@@ -4145,7 +4145,8 @@ int RGWHandler_Auth_S3::init(RGWRados *store, struct req_state *state,
   return RGWHandler_REST::init(store, state, cio);
 }
 
-RGWHandler_REST* RGWRESTMgr_S3::get_handler(struct req_state *s)
+RGWHandler_REST* RGWRESTMgr_S3::get_handler(struct req_state* const s,
+                                            const std::string& frontend_prefix)
 {
   bool is_s3website = enable_s3website && (s->prot_flags & RGW_REST_WEBSITE);
   int ret =
index 6793f5fdaf7d8d887881b69d9f826ce9e8f63f86..60218792c42dd222aed781ed11077a1a6e480623 100644 (file)
@@ -566,13 +566,14 @@ class RGWRESTMgr_S3 : public RGWRESTMgr {
 private:
   bool enable_s3website;
 public:
-  explicit RGWRESTMgr_S3(bool _enable_s3website = false)
-    : enable_s3website(_enable_s3website)
-    {}
+  explicit RGWRESTMgr_S3(bool enable_s3website = false)
+    : enable_s3website(enable_s3website) {
+  }
 
-  virtual ~RGWRESTMgr_S3() {}
+  virtual ~RGWRESTMgr_S3() = default;
 
-  virtual RGWHandler_REST *get_handler(struct req_state *s);
+  RGWHandler_REST *get_handler(struct req_state* s,
+                               const std::string& frontend_prefix) override;
 };
 
 class RGWHandler_REST_Obj_S3Website;
index 64995b1fcc3f09fc5231f626e8e89579104a6ee2..d19ff7e01ede27022db0e223b3147afc816e02a1 100644 (file)
@@ -2224,14 +2224,18 @@ static void next_tok(string& str, string& tok, char delim)
   }
 }
 
-int RGWHandler_REST_SWIFT::init_from_header(struct req_state *s)
+int RGWHandler_REST_SWIFT::init_from_header(struct req_state* const s,
+                                            const std::string& frontend_prefix)
 {
   string req;
   string first;
 
   s->prot_flags |= RGW_REST_SWIFT;
 
-  const char *req_name = s->decoded_uri.c_str();
+  char reqbuf[frontend_prefix.length() + s->decoded_uri.length() + 1];
+  sprintf(reqbuf, "%s%s", frontend_prefix.c_str(), s->decoded_uri.c_str());
+  const char *req_name = reqbuf;
+
   const char *p;
 
   if (*req_name == '?') {
@@ -2290,8 +2294,7 @@ int RGWHandler_REST_SWIFT::init_from_header(struct req_state *s)
                    g_conf->rgw_swift_url_prefix.c_str(), tenant_path.c_str());
   }
 
-  if (s->decoded_uri[0] != '/' ||
-    s->decoded_uri.compare(0, blen, buf) !=  0) {
+  if (strncmp(reqbuf, buf, blen) != 0) {
     return -ENOENT;
   }
 
@@ -2387,14 +2390,18 @@ int RGWHandler_REST_SWIFT::init(RGWRados* store, struct req_state* s,
   return RGWHandler_REST::init(store, s, cio);
 }
 
-RGWHandler_REST* RGWRESTMgr_SWIFT::get_handler(struct req_state *s)
+RGWHandler_REST* RGWRESTMgr_SWIFT::get_handler(struct req_state* const s,
+                                               const std::string& frontend_prefix)
 {
-  int ret = RGWHandler_REST_SWIFT::init_from_header(s);
-  if (ret < 0)
-    return NULL;
+  int ret = RGWHandler_REST_SWIFT::init_from_header(s, frontend_prefix);
+  if (ret < 0) {
+    ldout(s->cct, 10) << "init_from_header returned err=" << ret <<  dendl;
+    return nullptr;
+  }
 
-  if (s->init_state.url_bucket.empty())
+  if (s->init_state.url_bucket.empty()) {
     return new RGWHandler_REST_Service_SWIFT;
+  }
 
   if (s->object.empty()) {
     return new RGWHandler_REST_Bucket_SWIFT;
@@ -2403,7 +2410,9 @@ RGWHandler_REST* RGWRESTMgr_SWIFT::get_handler(struct req_state *s)
   return new RGWHandler_REST_Obj_SWIFT;
 }
 
-RGWHandler_REST* RGWRESTMgr_SWIFT_Info::get_handler(struct req_state *s)
+RGWHandler_REST* RGWRESTMgr_SWIFT_Info::get_handler(
+  struct req_state* const s,
+  const std::string& frontend_prefix)
 {
   s->prot_flags |= RGW_REST_SWIFT;
   return new RGWHandler_REST_SWIFT_Info;
index 4cc68ef6a07fbdbeb9fc3a418e4109bedc698a9a..a6ad103905a03fd1e3a12c28be047181e1665915 100644 (file)
@@ -259,7 +259,8 @@ protected:
     return false;
   }
 
-  static int init_from_header(struct req_state *s);
+  static int init_from_header(struct req_state* s,
+                              const std::string& frontend_prefix);
 public:
   RGWHandler_REST_SWIFT() {}
   virtual ~RGWHandler_REST_SWIFT() {}
@@ -360,17 +361,19 @@ public:
 };
 
 class RGWRESTMgr_SWIFT : public RGWRESTMgr {
-public:
-  RGWRESTMgr_SWIFT() {}
-  virtual ~RGWRESTMgr_SWIFT() {}
-
-  RGWHandler_REST *get_handler(struct req_state *s) override;
-
-  RGWRESTMgr* get_resource_mgr_as_default(struct req_state* s,
+protected:
+  RGWRESTMgr* get_resource_mgr_as_default(struct req_state* const s,
                                           const std::string& uri,
-                                          std::string* out_uri) override {
+                                          std::string* const out_uri) override {
     return this->get_resource_mgr(s, uri, out_uri);
   }
+
+public:
+  RGWRESTMgr_SWIFT() = default;
+  virtual ~RGWRESTMgr_SWIFT() = default;
+
+  RGWHandler_REST *get_handler(struct req_state *s,
+                               const std::string& frontend_prefix) override;
 };
 
 
@@ -428,17 +431,19 @@ public:
 };
 
 class RGWRESTMgr_SWIFT_CrossDomain : public RGWRESTMgr {
-public:
-  RGWRESTMgr_SWIFT_CrossDomain() = default;
-  ~RGWRESTMgr_SWIFT_CrossDomain() = default;
-
+protected:
   RGWRESTMgr *get_resource_mgr(struct req_state* const s,
                                const std::string& uri,
                                std::string* const out_uri) override {
     return this;
   }
 
-  RGWHandler_REST* get_handler(struct req_state* const s) override {
+public:
+  RGWRESTMgr_SWIFT_CrossDomain() = default;
+  ~RGWRESTMgr_SWIFT_CrossDomain() = default;
+
+  RGWHandler_REST* get_handler(struct req_state* const s,
+                               const std::string&) override {
     s->prot_flags |= RGW_REST_SWIFT;
     return new RGWHandler_SWIFT_CrossDomain;
   }
@@ -481,17 +486,19 @@ public:
 };
 
 class RGWRESTMgr_SWIFT_HealthCheck : public RGWRESTMgr {
-public:
-  RGWRESTMgr_SWIFT_HealthCheck() = default;
-  ~RGWRESTMgr_SWIFT_HealthCheck() = default;
-
+protected:
   RGWRESTMgr *get_resource_mgr(struct req_state* const s,
                                const std::string& uri,
                                std::string* const out_uri) override {
     return this;
   }
 
-  RGWHandler_REST* get_handler(struct req_state* const s) override {
+public:
+  RGWRESTMgr_SWIFT_HealthCheck() = default;
+  ~RGWRESTMgr_SWIFT_HealthCheck() = default;
+
+  RGWHandler_REST* get_handler(struct req_state* const s,
+                               const std::string&) override {
     s->prot_flags |= RGW_REST_SWIFT;
     return new RGWHandler_SWIFT_HealthCheck;
   }
@@ -534,7 +541,9 @@ class RGWRESTMgr_SWIFT_Info : public RGWRESTMgr {
 public:
   RGWRESTMgr_SWIFT_Info() = default;
   virtual ~RGWRESTMgr_SWIFT_Info() = default;
-  virtual RGWHandler_REST *get_handler(struct req_state *s) override;
+
+  RGWHandler_REST *get_handler(struct req_state* s,
+                               const std::string& frontend_prefix) override;
 };
 
 #endif
index e0963803f07f9464aa95e3a9a56a7711edf5a111..bc9d532db35b5594e10bcc25a57d9f5e8594eb7b 100644 (file)
@@ -23,10 +23,11 @@ public:
 
 class RGWRESTMgr_Usage : public RGWRESTMgr {
 public:
-  RGWRESTMgr_Usage() {}
-  virtual ~RGWRESTMgr_Usage() {}
+  RGWRESTMgr_Usage() = default;
+  virtual ~RGWRESTMgr_Usage() = default;
 
-  RGWHandler_REST* get_handler(struct req_state *s) {
+  RGWHandler_REST* get_handler(struct req_state*,
+                               const std::string&) override {
     return new RGWHandler_Usage;
   }
 };
index d3c399bb97a65ae2f293e71017c6f85ed18f1c98..4074ae600714f2e7b3d2810605e5196066921761 100644 (file)
@@ -25,10 +25,11 @@ public:
 
 class RGWRESTMgr_User : public RGWRESTMgr {
 public:
-  RGWRESTMgr_User() {}
-  virtual ~RGWRESTMgr_User() {}
+  RGWRESTMgr_User() = default;
+  virtual ~RGWRESTMgr_User() = default;
 
-  RGWHandler_REST *get_handler(struct req_state *s) {
+  RGWHandler_REST *get_handler(struct req_state*,
+                               const std::string&) override {
     return new RGWHandler_User;
   }
 };
index c4c7d0a076ee88badc3cd974be522a568b6996e3..4b1fa17b22bf0832a2248b6e9a0e3d71e46a4379 100644 (file)
@@ -151,13 +151,17 @@ public:
 
 class RGWRESTMgr_SWIFT_Auth : public RGWRESTMgr {
 public:
-  RGWRESTMgr_SWIFT_Auth() {}
-  virtual ~RGWRESTMgr_SWIFT_Auth() {}
+  RGWRESTMgr_SWIFT_Auth() = default;
+  virtual ~RGWRESTMgr_SWIFT_Auth() = default;
 
-  virtual RGWRESTMgr *get_resource_mgr(struct req_state *s, const string& uri, string *out_uri) {
+  virtual RGWRESTMgr *get_resource_mgr(struct req_state* const s,
+                                       const std::string& uri,
+                                       std::string* const out_uri) override {
     return this;
   }
-  virtual RGWHandler_REST* get_handler(struct req_state *s) {
+
+  virtual RGWHandler_REST* get_handler(struct req_state*,
+                                       const std::string&) override {
     return new RGWHandler_SWIFT_Auth;
   }
 };