Faidon has submitted this change and it was merged.

Change subject: Swift: add a document root container
......................................................................


Swift: add a document root container

Certain files need to reside in the root container, namely robots.txt,
crossdomain.xml and, less importantly, favicon.ico & index.html.

Add a "root" container and a rewrite.py rule that rewrites ^/[^/]*$ to
it.

Change-Id: I38b641e0f047f4d9efad88713acde6027a3e4e17
---
M files/swift/SwiftMedia/wmf/rewrite.py
1 file changed, 19 insertions(+), 0 deletions(-)

Approvals:
  Faidon: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/files/swift/SwiftMedia/wmf/rewrite.py 
b/files/swift/SwiftMedia/wmf/rewrite.py
index 3946000..db14f75 100644
--- a/files/swift/SwiftMedia/wmf/rewrite.py
+++ b/files/swift/SwiftMedia/wmf/rewrite.py
@@ -280,6 +280,25 @@
                     resp = webob.exc.HTTPNotFound('Monitoring type not found 
"%s"' % (req.path))
                 return resp(env, start_response)
 
+        if match is None:
+            match = re.match(r'^/(?P<path>[^/]+)?$', req.path)
+            # /index.html /favicon.ico /robots.txt etc.
+            # serve from a default "root" container
+            if match:
+                path  = match.group('path')
+                if not path:
+                    path = 'index.html'
+
+                req.host = '127.0.0.1:%s' % self.bind_port
+                req.path_info = "/v1/%s/root/%s" % (self.account, path)
+
+                app_iter = self._app_call(env)
+                status = self._get_status_int()
+                headers = self._response_headers
+
+                resp = webob.Response(status=status, headers=headers, 
app_iter=app_iter)
+                return resp(env, start_response)
+
         # Internally rewrite the URL based on the regex it matched...
         if match:
             # Get the per-project "conceptual" container name, e.g. 
"<proj><lang><repo><zone>"

-- 
To view, visit https://gerrit.wikimedia.org/r/56911
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I38b641e0f047f4d9efad88713acde6027a3e4e17
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Faidon <fai...@wikimedia.org>
Gerrit-Reviewer: Faidon <fai...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to