Skip to content
Browse files

Added djng.middleware.GZip and example of applying that middleware to…

… just one path within a site
  • Loading branch information...
1 parent 63afa89 commit 77d7b7c20b8a0561b4741ef777915376db8dbb0d Simon Willison committed May 18, 2009
Showing with 21 additions and 0 deletions.
  1. +1 −0 djng/__init__.py
  2. +5 −0 djng/middleware.py
  3. +15 −0 example_middleware.py
View
1 djng/__init__.py
@@ -3,6 +3,7 @@
settings.configure(USE_18N = False)
del settings
+import middleware
from django.conf.urls.defaults import url
from router import Router
from errors import ErrorWrapper
View
5 djng/middleware.py
@@ -0,0 +1,5 @@
+from django.utils.decorators import decorator_from_middleware
+from django.middleware.gzip import GZipMiddleware
+
+GZip = decorator_from_middleware(GZipMiddleware)
+del GZipMiddleware
View
15 example_middleware.py
@@ -0,0 +1,15 @@
+import djng
+
+def hello(request):
+ return djng.Response('Hello, world ' * 100)
+
+def goodbye(request):
+ return djng.Response('Goodbye, world ' * 100)
+
+app = djng.Router(
+ (r'^hello$', hello),
+ (r'^goodbye$', djng.middleware.GZip(goodbye)),
+)
+
+if __name__ == '__main__':
+ djng.serve(app, '0.0.0.0', 8888)

0 comments on commit 77d7b7c

Please sign in to comment.
Something went wrong with that request. Please try again.