Prepare for 21.3 release (#2057)
* Prepare for release * Add to changelog recent PRs * add missing changelog items and update contributing docs * Add 2061 * add 2060 to changelog * Add 20.12.3 to changelog * Add #2064 to changelog * Do not show host and port in README * Add some documentation PRs to changelog * add new decorators to changelog * Add 2063 * Add some PRs to misc
This commit is contained in:
parent
6763e2bb0a
commit
2586989eb7
244
CHANGELOG.rst
244
CHANGELOG.rst
|
@ -1,5 +1,211 @@
|
|||
Version 21.3.0
|
||||
--------------
|
||||
|
||||
`Release Notes <https://sanicframework.org/en/guide/release-notes/v21.3.html>`_
|
||||
|
||||
Features
|
||||
********
|
||||
|
||||
*
|
||||
`#1876 <https://github.com/sanic-org/sanic/pull/1876>`_
|
||||
Unified streaming server
|
||||
|
||||
*
|
||||
`#2005 <https://github.com/sanic-org/sanic/pull/2005>`_
|
||||
New ``Request.id`` property
|
||||
|
||||
*
|
||||
`#2008 <https://github.com/sanic-org/sanic/pull/2008>`_
|
||||
Allow Pathlib Path objects to be passed to ``app.static()`` helper
|
||||
|
||||
*
|
||||
`#2010 <https://github.com/sanic-org/sanic/pull/2010>`_, `#2031 <https://github.com/sanic-org/sanic/pull/2031>`_
|
||||
New startup-optimized router
|
||||
|
||||
*
|
||||
`#2018 <https://github.com/sanic-org/sanic/pull/2018>`_
|
||||
`#2064 <https://github.com/sanic-org/sanic/pull/2064>`_
|
||||
Listeners for main server process
|
||||
|
||||
*
|
||||
`#2032 <https://github.com/sanic-org/sanic/pull/2032>`_
|
||||
Add raw header info to request object
|
||||
|
||||
*
|
||||
`#2042 <https://github.com/sanic-org/sanic/pull/2042>`_
|
||||
`#2060 <https://github.com/sanic-org/sanic/pull/2060>`_
|
||||
`#2061 <https://github.com/sanic-org/sanic/pull/2061>`_
|
||||
Introduce Signals API
|
||||
|
||||
*
|
||||
`#2043 <https://github.com/sanic-org/sanic/pull/2043>`_
|
||||
Add ``__str__`` and ``__repr__`` to Sanic and Blueprint
|
||||
|
||||
*
|
||||
`#2047 <https://github.com/sanic-org/sanic/pull/2047>`_
|
||||
Enable versioning and strict slash on BlueprintGroup
|
||||
|
||||
*
|
||||
`#2053 <https://github.com/sanic-org/sanic/pull/2053>`_
|
||||
Make ``get_app`` name argument optional
|
||||
|
||||
*
|
||||
`#2055 <https://github.com/sanic-org/sanic/pull/2055>`_
|
||||
JSON encoder change via app
|
||||
|
||||
*
|
||||
`#2063 <https://github.com/sanic-org/sanic/pull/2063>`_
|
||||
App and connection level context objects
|
||||
|
||||
Bugfixes and issues resolved
|
||||
****************************
|
||||
|
||||
* Resolve `#1420 <https://github.com/sanic-org/sanic/pull/1420>`_
|
||||
``url_for`` where ``strict_slashes`` are on for a path ending in ``/``
|
||||
* Resolve `#1525 <https://github.com/sanic-org/sanic/pull/1525>`_
|
||||
Routing is incorrect with some special characters
|
||||
* Resolve `#1653 <https://github.com/sanic-org/sanic/pull/1653>`_
|
||||
ASGI headers in body
|
||||
* Resolve `#1722 <https://github.com/sanic-org/sanic/pull/1722>`_
|
||||
Using curl in chunk mode
|
||||
* Resolve `#1730 <https://github.com/sanic-org/sanic/pull/1730>`_
|
||||
Extra content in ASGI streaming response
|
||||
* Resolve `#1749 <https://github.com/sanic-org/sanic/pull/1749>`_
|
||||
Restore broken middleware edge cases
|
||||
* Resolve `#1785 <https://github.com/sanic-org/sanic/pull/1785>`_
|
||||
`#1804 <https://github.com/sanic-org/sanic/pull/1804>`_
|
||||
Synchronous error handlers
|
||||
* Resolve `#1790 <https://github.com/sanic-org/sanic/pull/1790>`_
|
||||
Protocol errors did not support async error handlers #1790
|
||||
* Resolve `#1824 <https://github.com/sanic-org/sanic/pull/1824>`_
|
||||
Timeout on specific methods
|
||||
* Resolve `#1875 <https://github.com/sanic-org/sanic/pull/1875>`_
|
||||
Response timeout error from all routes after returning several timeouts from a specific route
|
||||
* Resolve `#1988 <https://github.com/sanic-org/sanic/pull/1988>`_
|
||||
Handling of safe methods with body
|
||||
|
||||
*
|
||||
`#2001 <https://github.com/sanic-org/sanic/pull/2001>`_
|
||||
Raise ValueError when cookie max-age is not an integer
|
||||
|
||||
Deprecations and Removals
|
||||
*************************
|
||||
|
||||
*
|
||||
`#2007 <https://github.com/sanic-org/sanic/pull/2007>`_
|
||||
* Config using ``from_envvar``
|
||||
* Config using ``from_pyfile``
|
||||
* Config using ``from_object``
|
||||
*
|
||||
`#2009 <https://github.com/sanic-org/sanic/pull/2009>`_
|
||||
Remove Sanic test client to its own package
|
||||
|
||||
*
|
||||
`#2036 <https://github.com/sanic-org/sanic/pull/2036>`_,
|
||||
`#2037 <https://github.com/sanic-org/sanic/pull/2037>`_
|
||||
Drop Python 3.6 support
|
||||
|
||||
* ``Request.endpoint`` deprecated in favor of ``Request.name``
|
||||
* handler type name prefixes removed (static, websocket, etc)
|
||||
|
||||
Developer infrastructure
|
||||
************************
|
||||
|
||||
*
|
||||
`#1995 <https://github.com/sanic-org/sanic/pull/1995>`_
|
||||
Create FUNDING.yml
|
||||
|
||||
*
|
||||
`#2013 <https://github.com/sanic-org/sanic/pull/2013>`_
|
||||
Add codeql to CI pipeline
|
||||
|
||||
*
|
||||
`#2038 <https://github.com/sanic-org/sanic/pull/2038>`_
|
||||
Codecov configuration updates
|
||||
|
||||
*
|
||||
`#2049 <https://github.com/sanic-org/sanic/pull/2049>`_
|
||||
Updated setup.py to use ``find_packages``
|
||||
|
||||
Improved Documentation
|
||||
**********************
|
||||
|
||||
*
|
||||
`#1218 <https://github.com/sanic-org/sanic/pull/1218>`_
|
||||
Documentation for sanic.log.* is missing
|
||||
|
||||
*
|
||||
`#1608 <https://github.com/sanic-org/sanic/pull/1608>`_
|
||||
Add documentation on calver and LTS
|
||||
|
||||
*
|
||||
`#1731 <https://github.com/sanic-org/sanic/pull/1731>`_
|
||||
Support mounting application elsewhere than at root path
|
||||
|
||||
*
|
||||
`#2006 <https://github.com/sanic-org/sanic/pull/2006>`_
|
||||
Upgraded type annotations and improved docstrings and API documentation
|
||||
|
||||
*
|
||||
`#2052 <https://github.com/sanic-org/sanic/pull/2052>`_
|
||||
Fix some examples and docs
|
||||
|
||||
Miscellaneous
|
||||
*************
|
||||
|
||||
* ``Request.route`` property
|
||||
* Better websocket subprotocols support
|
||||
* Resolve bug with middleware in Blueprint Group when passed callable
|
||||
* Moves common logic between Blueprint and Sanic into mixins
|
||||
* Route naming changed to be more consistent
|
||||
* request endpoint is the route name
|
||||
* route names are fully namespaced
|
||||
* Some new convenience decorators:
|
||||
* ``@app.main_process_start``
|
||||
* ``@app.main_process_stop``
|
||||
* ``@app.before_server_start``
|
||||
* ``@app.after_server_start``
|
||||
* ``@app.before_server_stop``
|
||||
* ``@app.after_server_stop``
|
||||
* ``@app.on_request``
|
||||
* ``@app.on_response``
|
||||
* Fixes ``Allow`` header that did not include ``HEAD``
|
||||
* Using "name" keyword in ``url_for`` for a "static" route where name does not exist
|
||||
* Cannot have multiple ``app.static()`` without using the named param
|
||||
* Using "filename" keyword in ``url_for`` on a file route
|
||||
* ``unquote`` in route def (not automatic)
|
||||
* ``routes_all`` is tuples
|
||||
* Handler arguments are kwarg only
|
||||
* ``request.match_info`` is now a cached (and not computed) property
|
||||
* Unknown static file mimetype is sent as ``application/octet-stream``
|
||||
* ``_host`` keyword in ``url_for``
|
||||
* Add charset default to ``utf-8`` for text and js content types if not specified
|
||||
* Version for a route can be str, float, or int
|
||||
* Route has ctx property
|
||||
* App has ``routes_static``, ``routes_dynamic``, ``routes_regex``
|
||||
|
||||
*
|
||||
`#2044 <https://github.com/sanic-org/sanic/pull/2044>`_
|
||||
Code cleanup and refactoring
|
||||
*
|
||||
`#2072 <https://github.com/sanic-org/sanic/pull/2072>`_
|
||||
Remove ``BaseSanic`` metaclass
|
||||
*
|
||||
`#2074 <https://github.com/sanic-org/sanic/pull/2074>`_
|
||||
Performance adjustments in ``handle_request_``
|
||||
|
||||
Version 20.12.3
|
||||
---------------
|
||||
|
||||
Bugfixes
|
||||
********
|
||||
|
||||
*
|
||||
`#2021 <https://github.com/sanic-org/sanic/pull/2021>`_
|
||||
Remove prefix from websocket handler name
|
||||
|
||||
Version 20.12.2
|
||||
===============
|
||||
---------------
|
||||
|
||||
Dependencies
|
||||
************
|
||||
|
@ -13,7 +219,7 @@ Dependencies
|
|||
Remove old chardet requirement, add in hard multidict requirement
|
||||
|
||||
Version 19.12.5
|
||||
===============
|
||||
---------------
|
||||
|
||||
Dependencies
|
||||
************
|
||||
|
@ -27,7 +233,7 @@ Dependencies
|
|||
Remove old chardet requirement, add in hard multidict requirement
|
||||
|
||||
Version 20.12.0
|
||||
===============
|
||||
---------------
|
||||
|
||||
Features
|
||||
********
|
||||
|
@ -37,7 +243,7 @@ Features
|
|||
Add disable app registry
|
||||
|
||||
Version 20.12.0
|
||||
===============
|
||||
---------------
|
||||
|
||||
Features
|
||||
********
|
||||
|
@ -124,7 +330,7 @@ Improved Documentation
|
|||
|
||||
|
||||
Version 20.9.1
|
||||
===============
|
||||
---------------
|
||||
|
||||
Bugfixes
|
||||
********
|
||||
|
@ -138,7 +344,7 @@ Bugfixes
|
|||
|
||||
|
||||
Version 19.12.3
|
||||
===============
|
||||
---------------
|
||||
|
||||
Bugfixes
|
||||
********
|
||||
|
@ -149,7 +355,7 @@ Bugfixes
|
|||
|
||||
|
||||
Version 20.9.0
|
||||
===============
|
||||
---------------
|
||||
|
||||
|
||||
Features
|
||||
|
@ -219,7 +425,7 @@ Improved Documentation
|
|||
|
||||
|
||||
Version 20.6.3
|
||||
===============
|
||||
---------------
|
||||
|
||||
Bugfixes
|
||||
********
|
||||
|
@ -230,7 +436,7 @@ Bugfixes
|
|||
|
||||
|
||||
Version 20.6.2
|
||||
===============
|
||||
---------------
|
||||
|
||||
Features
|
||||
********
|
||||
|
@ -241,7 +447,7 @@ Features
|
|||
|
||||
|
||||
Version 20.6.1
|
||||
===============
|
||||
---------------
|
||||
|
||||
Features
|
||||
********
|
||||
|
@ -317,13 +523,13 @@ Improved Documentation
|
|||
|
||||
|
||||
Version 20.6.0
|
||||
===============
|
||||
---------------
|
||||
|
||||
*Released, but unintentionally ommitting PR #1880, so was replaced by 20.6.1*
|
||||
|
||||
|
||||
Version 20.3.0
|
||||
===============
|
||||
---------------
|
||||
|
||||
Features
|
||||
********
|
||||
|
@ -454,7 +660,7 @@ Improved Documentation
|
|||
|
||||
|
||||
Version 19.12.0
|
||||
===============
|
||||
---------------
|
||||
|
||||
Bugfixes
|
||||
********
|
||||
|
@ -489,7 +695,7 @@ Improved Documentation
|
|||
|
||||
|
||||
Version 19.6.3
|
||||
==============
|
||||
--------------
|
||||
|
||||
Features
|
||||
********
|
||||
|
@ -512,7 +718,7 @@ Improved Documentation
|
|||
|
||||
|
||||
Version 19.6.2
|
||||
==============
|
||||
--------------
|
||||
|
||||
Features
|
||||
********
|
||||
|
@ -573,7 +779,7 @@ Deprecations and Removals
|
|||
|
||||
|
||||
Version 19.3
|
||||
============
|
||||
------------
|
||||
|
||||
Features
|
||||
********
|
||||
|
@ -711,7 +917,7 @@ Improved Documentation
|
|||
Note: 19.3.0 was skipped for packagement purposes and not released on PyPI
|
||||
|
||||
Version 18.12
|
||||
=============
|
||||
-------------
|
||||
|
||||
18.12.0
|
||||
*******
|
||||
|
@ -756,7 +962,7 @@ Version 18.12
|
|||
* Fix document for logging
|
||||
|
||||
Version 0.8
|
||||
===========
|
||||
-----------
|
||||
|
||||
0.8.3
|
||||
*****
|
||||
|
@ -843,7 +1049,7 @@ Version 0.8
|
|||
Note: Changelog was unmaintained between 0.1 and 0.7
|
||||
|
||||
Version 0.1
|
||||
===========
|
||||
-----------
|
||||
|
||||
|
||||
0.1.7
|
||||
|
|
|
@ -1,20 +1,17 @@
|
|||
|
||||
Contributing
|
||||
============
|
||||
|
||||
Thank you for your interest! Sanic is always looking for contributors. If you
|
||||
don't feel comfortable contributing code, adding docstrings to the source files
|
||||
is very appreciated.
|
||||
don't feel comfortable contributing code, adding docstrings to the source files,
|
||||
or helping with the `Sanic User Guide <https://github.com/sanic-org/sanic-guide>`_
|
||||
by providing documentation or implementation examples would be appreciated!
|
||||
|
||||
We are committed to providing a friendly, safe and welcoming environment for all,
|
||||
regardless of gender, sexual orientation, disability, ethnicity, religion,
|
||||
or similar personal characteristic.
|
||||
Our `code of conduct <./CONDUCT.md>`_ sets the standards for behavior.
|
||||
Our `code of conduct <https://github.com/sanic-org/sanic/blob/master/CONDUCT.md>`_ sets the standards for behavior.
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
To develop on sanic (and mainly to just run the tests) it is highly recommend to
|
||||
To develop on Sanic (and mainly to just run the tests) it is highly recommend to
|
||||
install from sources.
|
||||
|
||||
So assume you have already cloned the repo and are in the working directory with
|
||||
|
@ -89,6 +86,17 @@ Permform ``flake8``\ , ``black`` and ``isort`` checks.
|
|||
|
||||
tox -e lint
|
||||
|
||||
Run type annotation checks
|
||||
---------------
|
||||
|
||||
``tox`` environment -> ``[testenv:type-checking]``
|
||||
|
||||
Permform ``mypy`` checks.
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
tox -e type-checking
|
||||
|
||||
Run other checks
|
||||
----------------
|
||||
|
||||
|
@ -161,6 +169,12 @@ flake8
|
|||
|
||||
``isort``\ , ``black`` and ``flake8`` checks are performed during ``tox`` lint checks.
|
||||
|
||||
The **easiest** way to make your code conform is to run the following before committing.
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
make pretty
|
||||
|
||||
Refer `tox <https://tox.readthedocs.io/en/latest/index.html>`_ documentation for more details.
|
||||
|
||||
Pull requests
|
||||
|
@ -168,12 +182,13 @@ Pull requests
|
|||
|
||||
So the pull request approval rules are pretty simple:
|
||||
|
||||
#. All pull requests must have a changelog details associated with it.
|
||||
#. All pull requests must pass unit tests.
|
||||
#. All pull requests must be reviewed and approved by at least one current collaborator on the project.
|
||||
#. All pull requests must be reviewed and approved by at least one current member of the Core Developer team.
|
||||
#. All pull requests must pass flake8 checks.
|
||||
#. All pull requests must match ``isort`` and ``black`` requirements.
|
||||
#. All pull requests must be **PROPERLY** type annotated, unless exemption is given.
|
||||
#. All pull requests must be consistent with the existing code.
|
||||
#. If you decide to remove/change anything from any common interface a deprecation message should accompany it.
|
||||
#. If you decide to remove/change anything from any common interface a deprecation message should accompany it in accordance with our `deprecation policy <https://sanicframework.org/en/guide/project/policies.html#deprecation>`_.
|
||||
#. If you implement a new feature you should have at least one unit test to accompany it.
|
||||
#. An example must be one of the following:
|
||||
|
||||
|
@ -182,56 +197,14 @@ So the pull request approval rules are pretty simple:
|
|||
* Example of how to use Sanic and asynchronous library
|
||||
|
||||
|
||||
Changelog
|
||||
---------
|
||||
|
||||
It is mandatory to add documentation for Change log as part of your Pull request when you fix/contribute something
|
||||
to the ``sanic`` community. This will enable us in generating better and well defined change logs during the
|
||||
release which can aid community users in a great way.
|
||||
|
||||
.. note::
|
||||
|
||||
Single line explaining the details of the PR in brief
|
||||
|
||||
Detailed description of what the PR is about and what changes or enhancements are being done.
|
||||
No need to include examples or any other details here. But it is important that you provide
|
||||
enough context here to let user understand what this change is all about and why it is being
|
||||
introduced into the ``sanic`` codebase.
|
||||
|
||||
Make sure you leave an line space after the first line to make sure the document rendering is clean
|
||||
|
||||
|
||||
.. list-table::
|
||||
:header-rows: 1
|
||||
|
||||
* - Contribution Type
|
||||
- Changelog file name format
|
||||
- Changelog file location
|
||||
* - Features
|
||||
- <git_issue>.feature.rst
|
||||
- ``changelogs``
|
||||
* - Bugfixes
|
||||
- <git_issue>.bugfix.rst
|
||||
- ``changelogs``
|
||||
* - Improved Documentation
|
||||
- <git_issue>.doc.rst
|
||||
- ``changelogs``
|
||||
* - Deprecations and Removals
|
||||
- <git_issue>.removal.rst
|
||||
- ``changelogs``
|
||||
* - Miscellaneous internal changes
|
||||
- <git_issue>.misc.rst
|
||||
- ``changelogs``
|
||||
|
||||
|
||||
Documentation
|
||||
-------------
|
||||
|
||||
Sanic's documentation is built
|
||||
using `sphinx <http://www.sphinx-doc.org/en/1.5.1/>`_. Guides are written in
|
||||
Markdown and can be found in the ``docs`` folder, while the module reference is
|
||||
Sanic's API documentation is built using `sphinx <http://www.sphinx-doc.org/en/1.5.1/>`_ with module references
|
||||
automatically generated using ``sphinx-apidoc``.
|
||||
|
||||
The User Guide is in the `sanic-guide <https://github.com/sanic-org/sanic-guide>`_ repository.
|
||||
|
||||
To generate the documentation from scratch:
|
||||
|
||||
.. code-block:: bash
|
||||
|
@ -245,6 +218,14 @@ To generate the documentation from scratch:
|
|||
|
||||
The HTML documentation will be created in the ``docs/_build`` folder.
|
||||
|
||||
You can run the following to have a live development server with the API documents
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
make docs-serve
|
||||
|
||||
Refer to the User Guide repo for documentation on how to contribute there.
|
||||
|
||||
.. warning::
|
||||
One of the main goals of Sanic is speed. Code that lowers the performance of
|
||||
Sanic without significant gains in usability, security, or features may not be
|
||||
|
|
12
README.rst
12
README.rst
|
@ -66,7 +66,7 @@ Sanic is a **Python 3.7+** web server and web framework that's written to go fas
|
|||
|
||||
Sanic is also ASGI compliant, so you can deploy it with an `alternative ASGI webserver <https://sanic.readthedocs.io/en/latest/sanic/deploying.html#running-via-asgi>`_.
|
||||
|
||||
`Source code on GitHub <https://github.com/sanic-org/sanic/>`_ | `Help and discussion board <https://community.sanicframework.org/>`_ | `User Guide <https://sanicframework.org>`_
|
||||
`Source code on GitHub <https://github.com/sanic-org/sanic/>`_ | `Help and discussion board <https://community.sanicframework.org/>`_ | `User Guide <https://sanicframework.org>`_ | `Chat on Discord <https://discord.gg/FARQzAEMAA>`_
|
||||
|
||||
The project is maintained by the community, for the community. **Contributions are welcome!**
|
||||
|
||||
|
@ -125,13 +125,13 @@ Hello World Example
|
|||
return json({'hello': 'world'})
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(host='0.0.0.0', port=8000)
|
||||
app.run()
|
||||
|
||||
Sanic can now be easily run using ``sanic hello.app``.
|
||||
|
||||
.. code::
|
||||
|
||||
[2018-12-30 11:37:41 +0200] [13564] [INFO] Goin' Fast @ http://0.0.0.0:8000
|
||||
[2018-12-30 11:37:41 +0200] [13564] [INFO] Goin' Fast @ http://127.0.0.1:8000
|
||||
[2018-12-30 11:37:41 +0200] [13564] [INFO] Starting worker [13564]
|
||||
|
||||
And, we can verify it is working: ``curl localhost:8000 -i``
|
||||
|
@ -153,18 +153,18 @@ Minimum Python version is 3.7. If you need Python 3.6 support, please use v20.12
|
|||
Documentation
|
||||
-------------
|
||||
|
||||
`User Guide <https://sanicframework.org>`_ and `API Documentation <http://sanic.readthedocs.io/>`_.
|
||||
`User Guide <https://sanicframework.org>`__ and `API Documentation <http://sanic.readthedocs.io/>`__.
|
||||
|
||||
Changelog
|
||||
---------
|
||||
|
||||
`Release Changelogs <https://github.com/sanic-org/sanic/blob/master/CHANGELOG.rst>`_.
|
||||
`Release Changelogs <https://github.com/sanic-org/sanic/blob/master/CHANGELOG.rst>`__.
|
||||
|
||||
|
||||
Questions and Discussion
|
||||
------------------------
|
||||
|
||||
`Ask a question or join the conversation <https://community.sanicframework.org/>`_.
|
||||
`Ask a question or join the conversation <https://community.sanicframework.org/>`__.
|
||||
|
||||
Contribution
|
||||
------------
|
||||
|
|
|
@ -3,18 +3,21 @@
|
|||
User Guide
|
||||
==========
|
||||
|
||||
To learn about using Sanic, checkout the `User Guide <https://sanicframework.org/guide/>`_.
|
||||
To learn about using Sanic, checkout the `User Guide <https://sanicframework.org/guide/>`__.
|
||||
|
||||
API
|
||||
======
|
||||
===
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 4
|
||||
:maxdepth: 2
|
||||
|
||||
👥 User Guide <https://sanicframework.org/guide/>
|
||||
sanic/api_reference
|
||||
💻 Source code <https://github.com/sanic-org/sanic/>
|
||||
sanic/changelog
|
||||
sanic/contributing
|
||||
❓ Support <https://community.sanicframework.org/>
|
||||
💬 Chat <https://discord.gg/FARQzAEMAA>
|
||||
|
||||
|
||||
Module Documentation
|
||||
|
|
4
docs/sanic/changelog.rst
Normal file
4
docs/sanic/changelog.rst
Normal file
|
@ -0,0 +1,4 @@
|
|||
📜 Changelog
|
||||
============
|
||||
|
||||
.. include:: ../../CHANGELOG.rst
|
4
docs/sanic/contributing.rst
Normal file
4
docs/sanic/contributing.rst
Normal file
|
@ -0,0 +1,4 @@
|
|||
♥️ Contributing
|
||||
===============
|
||||
|
||||
.. include:: ../../CONTRIBUTING.rst
|
51
examples/http_redirect.py
Normal file
51
examples/http_redirect.py
Normal file
|
@ -0,0 +1,51 @@
|
|||
from sanic import Sanic, response, text
|
||||
|
||||
|
||||
HTTP_PORT = 9999
|
||||
HTTPS_PORT = 8888
|
||||
|
||||
http = Sanic("http")
|
||||
http.config.SERVER_NAME = f"localhost:{HTTP_PORT}"
|
||||
https = Sanic("https")
|
||||
https.config.SERVER_NAME = f"localhost:{HTTPS_PORT}"
|
||||
|
||||
|
||||
@https.get("/foo")
|
||||
def foo(request):
|
||||
return text("foo")
|
||||
|
||||
|
||||
@https.get("/bar")
|
||||
def bar(request):
|
||||
return text("bar")
|
||||
|
||||
|
||||
@http.get("/<path:path>")
|
||||
def proxy(request, path):
|
||||
url = request.app.url_for(
|
||||
"proxy",
|
||||
path=path,
|
||||
_server=https.config.SERVER_NAME,
|
||||
_external=True,
|
||||
_scheme="http",
|
||||
)
|
||||
return response.redirect(url)
|
||||
|
||||
|
||||
@https.listener("main_process_start")
|
||||
async def start(app, _):
|
||||
global http
|
||||
app.http_server = await http.create_server(
|
||||
port=HTTP_PORT, return_asyncio_server=True
|
||||
)
|
||||
app.http_server.after_start()
|
||||
|
||||
|
||||
@https.listener("main_process_stop")
|
||||
async def stop(app, _):
|
||||
app.http_server.before_stop()
|
||||
await app.http_server.close()
|
||||
app.http_server.after_stop()
|
||||
|
||||
|
||||
https.run(port=HTTPS_PORT, debug=True)
|
|
@ -1 +1 @@
|
|||
__version__ = "21.3.0a1"
|
||||
__version__ = "21.3.0"
|
||||
|
|
Loading…
Reference in New Issue
Block a user