Add syntatic sugar for route registration

This takes a popular API whereby instead of passing the HTTP method as
an argument to route it is instead used as the method name i.e.

    @app.route("/", methods=["POST"])

is now writeable as,

    @app.post("/")

This is simply syntatic sugar, it doesn't do anything else, but makes
it slightly easier for users.

I've included all the methods that are relevant and aren't auto
generated i.e. not connect, head, options, and trace.
This commit is contained in:
pgjones 2021-02-14 11:08:21 +00:00 committed by David Lord
parent 82d69cd06c
commit 705e52684a
No known key found for this signature in database
GPG key ID: 7A1C87E3F5BC42A8
3 changed files with 61 additions and 0 deletions

View file

@ -64,6 +64,9 @@ Unreleased
This could allow a session interface to change behavior based on
``request.endpoint``. :issue:`3776`
- Use Jinja's implementation of the ``|tojson`` filter. :issue:`3881`
- Add route decorators for common HTTP methods. For example,
``@app.post("/login")`` is a shortcut for
``@app.route("/login", methods=["POST"])``. :pr:`3907`
Version 1.1.2