Skip to content

Commit

Permalink
Added djng.middleware.GZip and example of applying that middleware to…
Browse files Browse the repository at this point in the history
… just one path within a site
  • Loading branch information
Simon Willison committed May 18, 2009
1 parent 63afa89 commit 77d7b7c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions djng/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions djng/middleware.py
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions example_middleware.py
Original file line number Diff line number Diff line change
@@ -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.