From 35ed7ceefba346af7961e336dc3ee74be4394e2d Mon Sep 17 00:00:00 2001 From: Channel Cat Date: Fri, 14 Oct 2016 04:58:09 -0700 Subject: [PATCH] . --- docs/exceptions.md | 2 +- docs/getting_started.md | 4 ++-- docs/middleware.md | 4 ++++ docs/routing.md | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/exceptions.md b/docs/exceptions.md index 92634bab..4889cd7b 100644 --- a/docs/exceptions.md +++ b/docs/exceptions.md @@ -1,6 +1,6 @@ # Exceptions -Check sanic.exceptions for a list of exceptions +Exceptions can be thrown from within request handlers and will automatically be handled by Sanic. Exceptions take a message as their first argument, and can also take a status_code to be passed back in the HTTP response. Check sanic.exceptions for the full list of exceptions to throw. ## Throwing an exception diff --git a/docs/getting_started.md b/docs/getting_started.md index 54882cda..0fd26bef 100644 --- a/docs/getting_started.md +++ b/docs/getting_started.md @@ -5,8 +5,8 @@ Make sure you have pip and python 3.5 before starting ## Benchmarks * Install Sanic * `python3 -m pip install git+https://github.com/channelcat/sanic/` - * Edit main.py - * ```python3 + * Edit main.py to include: +```python from sanic import Sanic from sanic.response import json diff --git a/docs/middleware.md b/docs/middleware.md index 3e257b84..3a6b74dc 100644 --- a/docs/middleware.md +++ b/docs/middleware.md @@ -10,6 +10,10 @@ Middleware is registered via the middleware decorator, and can either be added a app = Sanic('__name__') @app.middleware +async def halt_request(request): + print("I am a spy") + +@app.middleware('request') async def halt_request(request): return text('I halted the request') diff --git a/docs/routing.md b/docs/routing.md index ed252036..171639dc 100644 --- a/docs/routing.md +++ b/docs/routing.md @@ -7,7 +7,7 @@ Sanic comes with a basic router that supports request parameters. To specify a ```python from sanic import Sanic -from sanic.response import json +from sanic.response import text @app.route('/tag/') async def person_handler(request, tag):