sanic/examples
L. Kärkkäinen a62c84a954
Socket binding implemented properly for IPv6 and UNIX sockets. (#1641)
* Socket binding implemented properly for IPv6 and UNIX sockets.

- app.run("::1") for IPv6
- app.run("unix:/tmp/server.sock") for UNIX sockets
- app.run("localhost") retains old functionality (randomly either IPv4 or IPv6)

Do note that IPv6 and UNIX sockets are not fully supported by other Sanic facilities.
In particular, request.server_name and request.server_port are currently unreliable.

* Fix Windows compatibility by not referring to socket.AF_UNIX unless needed.

* Compatibility fix.

* Fix test of existing unix socket.

* Cleaner unix socket removal.

* Remove unix socket on exit also with workers=1.

* More pedantic UNIX socket implementation.

* Refactor app to take unix= argument instead of unix:-prefixed host. Goin' fast @ unix-socket fixed.

* Linter

* Proxy properties cleanup. Slight changes of semantics. SERVER_NAME now overrides everything.

* Have server fill in connection info instead of request asking the socket.

- Would be a good idea to remove request.transport entirely but I didn't dare to touch it yet.

* Linter 💣🌟💀

* Fix typing issues. request.server_name returns empty string if host header is missing.

* Fix tests

* Tests were failing, fix connection info.

* Linter nazi says you need that empty line.

* Rename a to addr, leave client empty for unix sockets.

* Add --unix support when sanic is run as module.

* Remove remove_route, deprecated in 19.6.

* Improved unix socket binding.

* More robust creating and unlinking of sockets. Show proper and not temporary name in conn_info.

* Add comprehensive tests for unix socket mode.

* Hide some imports inside functions to avoid Windows failure.

* Mention unix socket mode in deployment docs.

* Fix merge commit.

* Make test_unix_connection_multiple_workers pickleable for spawn mode multiprocessing.

Co-authored-by: L. Kärkkäinen <tronic@users.noreply.github.com>
Co-authored-by: Adam Hopkins <admhpkns@gmail.com>
2020-06-29 08:55:32 +03:00
..
request_stream Pausable response streams (#1179) 2018-08-18 18:12:13 -07:00
add_task_sanic.py feat(exapmles): add add_task_sanic.py 2017-08-20 11:11:14 +08:00
amending_request_object.py Add example of amending request object 2019-01-02 14:52:25 +08:00
authorized_sanic.py Reduce nesting for the sample authentication decorator (#1715) 2019-11-14 14:57:41 -06:00
blueprint_middlware_execution_order.py Reverse named_response_middlware execution order, to match normal response middleware execution order. 2020-05-14 09:54:47 +10:00
blueprints.py fix one example and add one example (#1257) 2018-07-11 01:42:34 -07:00
delayed_response.py Socket binding implemented properly for IPv6 and UNIX sockets. (#1641) 2020-06-29 08:55:32 +03:00
docker-compose.yml Added examples and form processing 2016-10-09 15:28:31 -07:00
Dockerfile Added examples and form processing 2016-10-09 15:28:31 -07:00
exception_monitoring.py reverted back to default 0.0.0.0 host 2017-06-01 14:01:13 -07:00
limit_concurrency.py Clean up of examples. Removes non-core examples, optimizes and restyles remaining to strictly follow PEP 8 styling guidelines. Non-Core examples will be moved to Wiki. 2017-06-01 11:53:05 -07:00
log_request_id.py Fix #1551 missing parameter in create_server 2019-04-15 22:18:35 +02:00
logdna_example.py add monitoring examples and documents 2018-12-28 10:22:28 +05:30
modify_header_example.py Clean up of examples. Removes non-core examples, optimizes and restyles remaining to strictly follow PEP 8 styling guidelines. Non-Core examples will be moved to Wiki. 2017-06-01 11:53:05 -07:00
override_logging.py Clean up of examples. Removes non-core examples, optimizes and restyles remaining to strictly follow PEP 8 styling guidelines. Non-Core examples will be moved to Wiki. 2017-06-01 11:53:05 -07:00
pytest_xdist.py Let SanicTestClient has its own port 2017-11-06 17:29:32 +09:00
raygun_example.py add monitoring examples and documents 2018-12-28 10:22:28 +05:30
redirect_example.py Clean up of examples. Removes non-core examples, optimizes and restyles remaining to strictly follow PEP 8 styling guidelines. Non-Core examples will be moved to Wiki. 2017-06-01 11:53:05 -07:00
request_timeout.py Clean up of examples. Removes non-core examples, optimizes and restyles remaining to strictly follow PEP 8 styling guidelines. Non-Core examples will be moved to Wiki. 2017-06-01 11:53:05 -07:00
rollbar_example.py add monitoring examples and documents 2018-12-28 10:22:28 +05:30
run_asgi.py Add placement of before_server_start and after_server_stop 2019-06-04 12:59:15 +03:00
run_async_advanced.py Fixes "after_server_start" when using return_asyncio_server. (#1676) 2019-09-16 10:59:16 -07:00
run_async.py Fix #1551 missing parameter in create_server 2019-04-15 22:18:35 +02:00
sentry_example.py add monitoring examples and documents 2018-12-28 10:22:28 +05:30
simple_async_view.py fix one example and add one example (#1257) 2018-07-11 01:42:34 -07:00
simple_server.py Updated examples for 0.5.0 2017-04-11 20:34:55 +00:00
teapot.py add status codes and teapot example 2017-09-13 14:08:29 +02:00
try_everything.py rename function to something else 2018-03-29 15:57:10 -07:00
unix_socket.py Clean up of examples. Removes non-core examples, optimizes and restyles remaining to strictly follow PEP 8 styling guidelines. Non-Core examples will be moved to Wiki. 2017-06-01 11:53:05 -07:00
url_for_example.py Clean up of examples. Removes non-core examples, optimizes and restyles remaining to strictly follow PEP 8 styling guidelines. Non-Core examples will be moved to Wiki. 2017-06-01 11:53:05 -07:00
vhosts.py Clean up of examples. Removes non-core examples, optimizes and restyles remaining to strictly follow PEP 8 styling guidelines. Non-Core examples will be moved to Wiki. 2017-06-01 11:53:05 -07:00
websocket.html websocket support, using websockets package 2017-02-27 22:35:28 -08:00
websocket.py Clean up of examples. Removes non-core examples, optimizes and restyles remaining to strictly follow PEP 8 styling guidelines. Non-Core examples will be moved to Wiki. 2017-06-01 11:53:05 -07:00