From da4567eea5f84d208f7fbadb1bac7e310297a319 Mon Sep 17 00:00:00 2001 From: Anton Zhyrney Date: Sat, 26 Nov 2016 08:44:46 +0200 Subject: [PATCH] changes in doc --- docs/class_based_views.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/class_based_views.md b/docs/class_based_views.md index b5f8ee02..c4ceeb0c 100644 --- a/docs/class_based_views.md +++ b/docs/class_based_views.md @@ -1,30 +1,30 @@ # Class based views -Sanic has simple class based implementation. You should implement methods(get, post, put, patch, delete) for the class to every HTTP method you want to support. If someone try to use not implemented method, there will be 405 response. +Sanic has simple class based implementation. You should implement methods(get, post, put, patch, delete) for the class to every HTTP method you want to support. If someone tries to use a method that has not been implemented, there will be 405 response. ## Examples ```python from sanic import Sanic -from sanic.views import MethodView +from sanic.views import HTTPMethodView app = Sanic('some_name') -class SimpleView(MethodView): +class SimpleView(HTTPMethodView): - def get(self, request, *args, **kwargs): + def get(self, request): return text('I am get method') - def post(self, request, *args, **kwargs): + def post(self, request): return text('I am post method') - def put(self, request, *args, **kwargs): + def put(self, request): return text('I am put method') - def patch(self, request, *args, **kwargs): + def patch(self, request): return text('I am patch method') - def delete(self, request, *args, **kwargs): + def delete(self, request): return text('I am delete method') app.add_route(SimpleView(), '/') @@ -34,9 +34,9 @@ app.add_route(SimpleView(), '/') If you need any url params just mention them in method definition: ```python -class NameView(MethodView): +class NameView(HTTPMethodView): - def get(self, request, name, *args, **kwargs): + def get(self, request, name): return text('Hello {}'.format(name)) app.add_route(NameView(), '/