From 3c7a8a5f4557ad809dedc36367d09c69226f3901 Mon Sep 17 00:00:00 2001 From: abhishek7 Date: Sun, 16 Oct 2016 11:35:45 -0400 Subject: [PATCH] Added some documentation to request.py, removed extra line in blueprints.py, and minor grammar enhancements to blueprints.md and middleware.md --- docs/blueprints.md | 4 ++-- docs/middleware.md | 2 +- sanic/blueprints.py | 1 - sanic/request.py | 3 +++ 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/blueprints.md b/docs/blueprints.md index 10d80e65..c7e6b02c 100644 --- a/docs/blueprints.md +++ b/docs/blueprints.md @@ -3,7 +3,7 @@ Blueprints are objects that can be used for sub-routing within an application. Instead of adding routes to the application object, blueprints define similar methods for adding routes, which are then registered with the application in a -flexible and plugable manner. +flexible and pluggable manner. ## Why? @@ -82,4 +82,4 @@ with other blueprints or routes registered on the application object. @bp.exception(NotFound) def ignore_404s(request, exception): return text("Yep, I totally found the page: {}".format(request.url)) -``` \ No newline at end of file +``` diff --git a/docs/middleware.md b/docs/middleware.md index 644af5a6..0b27443c 100644 --- a/docs/middleware.md +++ b/docs/middleware.md @@ -1,6 +1,6 @@ # Middleware -Middleware can be executed before or after requests. It is executed in the order it was registered. If middleware return a response object, the request will stop processing and a response will be returned. +Middleware can be executed before or after requests. It is executed in the order it was registered. If middleware returns a response object, the request will stop processing and a response will be returned. Middleware is registered via the middleware decorator, and can either be added as 'request' or 'response' middleware, based on the argument provided in the decorator. Response middleware receives both the request and the response as arguments. diff --git a/sanic/blueprints.py b/sanic/blueprints.py index b3b40df9..ab153b8b 100644 --- a/sanic/blueprints.py +++ b/sanic/blueprints.py @@ -76,7 +76,6 @@ class Blueprint: def middleware(self, *args, **kwargs): """ """ - def register_middleware(middleware): self.record(lambda s: s.add_middleware(middleware, *args, **kwargs)) return middleware diff --git a/sanic/request.py b/sanic/request.py index 85dcad46..196be534 100644 --- a/sanic/request.py +++ b/sanic/request.py @@ -26,6 +26,9 @@ class RequestParameters(dict): class Request: + """ + Properties of an HTTP request such as URL, headers, etc. + """ __slots__ = ( 'url', 'headers', 'version', 'method', 'query_string', 'body',