From fa5634ecde047472570657974b3c0236f2592abc Mon Sep 17 00:00:00 2001 From: SoyJoseC <31358201+SoyJoseC@users.noreply.github.com> Date: Sat, 16 Nov 2024 10:45:10 -0400 Subject: [PATCH 1/4] doc: Adds updated documentation on middleware ordering, issue #302 --- README.md | 2 +- docs/troubleshooting.rst | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 45cfd192..c4062ad1 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ INSTALLED_APPS = ( ) ``` -**Note:** The middleware placement is sensitive. If the middleware before `silk.middleware.SilkyMiddleware` returns from `process_request` then `SilkyMiddleware` will never get the chance to execute. Therefore you must ensure that any middleware placed before never returns anything from `process_request`. See the [django docs](https://docs.djangoproject.com/en/dev/topics/http/middleware/#process-request) for more information on this. +**Note:** The order of middleware is sensitive. If any middleware placed before `silk.middleware.SilkyMiddleware` returns a response without invoking its `get_response`, the `SilkyMiddleware` won’t run. To avoid this, ensure that middleware preceding `SilkyMiddleware` does not bypass or return a response without calling its `get_response`. For further details, check out the [Django documentation](https://docs.djangoproject.com/en/5.1/topics/http/middleware/#middleware-order-and-layering). **Note:** If you are using `django.middleware.gzip.GZipMiddleware`, place that **before** `silk.middleware.SilkyMiddleware`, otherwise you will get an encoding error. diff --git a/docs/troubleshooting.rst b/docs/troubleshooting.rst index 97ff2bdf..fec3d50c 100644 --- a/docs/troubleshooting.rst +++ b/docs/troubleshooting.rst @@ -21,9 +21,9 @@ See this `github issue `_ for Middleware ---------- -The middleware is placement sensitive. If the middleware before ``silk.middleware.SilkyMiddleware`` returns from ``process_request`` then ``SilkyMiddleware`` will never get the chance to execute. Therefore you must ensure that any middleware placed before never returns anything from ``process_request``. See the `django docs `_ for more information on this. +The order of middleware is sensitive. If any middleware placed before ``silk.middleware.SilkyMiddleware`` returns a response without invoking its ``get_response``, the ``SilkyMiddleware`` won’t run. To avoid this, ensure that middleware preceding ``SilkyMiddleware`` does not bypass or return a response without calling its ``get_response``. For further details, check out the `Django documentation `. -This `GitHub issue `_ also has information on dealing with middleware problems. +This `GitHub issue `_ also has information on dealing with middleware problems.` Garbage Collection ------------------ From 6437a14b472380dd12a64ee55dd8c503291c9d9e Mon Sep 17 00:00:00 2001 From: SoyJoseC <31358201+SoyJoseC@users.noreply.github.com> Date: Sun, 1 Dec 2024 16:25:15 -0400 Subject: [PATCH 2/4] Update README.md Changing the link to the developer documentation --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c4062ad1..3b1c2116 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ INSTALLED_APPS = ( ) ``` -**Note:** The order of middleware is sensitive. If any middleware placed before `silk.middleware.SilkyMiddleware` returns a response without invoking its `get_response`, the `SilkyMiddleware` won’t run. To avoid this, ensure that middleware preceding `SilkyMiddleware` does not bypass or return a response without calling its `get_response`. For further details, check out the [Django documentation](https://docs.djangoproject.com/en/5.1/topics/http/middleware/#middleware-order-and-layering). +**Note:** The order of middleware is sensitive. If any middleware placed before `silk.middleware.SilkyMiddleware` returns a response without invoking its `get_response`, the `SilkyMiddleware` won’t run. To avoid this, ensure that middleware preceding `SilkyMiddleware` does not bypass or return a response without calling its `get_response`. For further details, check out the [Django documentation](https://docs.djangoproject.com/en/dev/topics/http/middleware/#middleware-order-and-layering). **Note:** If you are using `django.middleware.gzip.GZipMiddleware`, place that **before** `silk.middleware.SilkyMiddleware`, otherwise you will get an encoding error. From 1cdd4ced58b5f208581f30f6272357dbc88a1746 Mon Sep 17 00:00:00 2001 From: SoyJoseC <31358201+SoyJoseC@users.noreply.github.com> Date: Sun, 1 Dec 2024 16:26:50 -0400 Subject: [PATCH 3/4] Update troubleshooting.rst Removing old issue link --- docs/troubleshooting.rst | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/troubleshooting.rst b/docs/troubleshooting.rst index fec3d50c..2dd2b64c 100644 --- a/docs/troubleshooting.rst +++ b/docs/troubleshooting.rst @@ -23,8 +23,6 @@ Middleware The order of middleware is sensitive. If any middleware placed before ``silk.middleware.SilkyMiddleware`` returns a response without invoking its ``get_response``, the ``SilkyMiddleware`` won’t run. To avoid this, ensure that middleware preceding ``SilkyMiddleware`` does not bypass or return a response without calling its ``get_response``. For further details, check out the `Django documentation `. -This `GitHub issue `_ also has information on dealing with middleware problems.` - Garbage Collection ------------------ From 9645c7999e7ce3919502568bfbbdd001efb4e1d8 Mon Sep 17 00:00:00 2001 From: SoyJoseC <31358201+SoyJoseC@users.noreply.github.com> Date: Sun, 1 Dec 2024 20:40:02 -0400 Subject: [PATCH 4/4] Update troubleshooting.rst Changing the documentation link to the developer version --- docs/troubleshooting.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/troubleshooting.rst b/docs/troubleshooting.rst index 2dd2b64c..cf31bda9 100644 --- a/docs/troubleshooting.rst +++ b/docs/troubleshooting.rst @@ -21,7 +21,7 @@ See this `github issue `_ for Middleware ---------- -The order of middleware is sensitive. If any middleware placed before ``silk.middleware.SilkyMiddleware`` returns a response without invoking its ``get_response``, the ``SilkyMiddleware`` won’t run. To avoid this, ensure that middleware preceding ``SilkyMiddleware`` does not bypass or return a response without calling its ``get_response``. For further details, check out the `Django documentation `. +The order of middleware is sensitive. If any middleware placed before ``silk.middleware.SilkyMiddleware`` returns a response without invoking its ``get_response``, the ``SilkyMiddleware`` won’t run. To avoid this, ensure that middleware preceding ``SilkyMiddleware`` does not bypass or return a response without calling its ``get_response``. For further details, check out the `Django documentation `. Garbage Collection ------------------