This release adds a few quality of life improvement for the Router and a way to serve static files. It also includes a bump in test coverage.
Summary
Serve static files
If you have a module with resources (say, `my_app.static`), you can serve them directly through:
python
from my_app import static
route("/static/<path:path>")
def handler(request, path):
return Response.for_resource(static, path)
The mimetype will be set automatically from the resource's file name.
Return lists from handlers
Using a handler dispatcher, you can now return not only dictionaries but also lists to be converted into json responses:
python
route("/list")
def handler(request):
return [{"id": 1}, {"id": 2}, {"id": 3}]
Will generate an appropriate json response.
Serve a Router as wsgi app.
You can now serve a `Router` instance as wsgi app by calling `Router.wsgi()`.
python
from werkzeug.serving import run_simple
from rolo import Router
from rolo.dispatcher import handler_dispatcher
router = Router(dispatcher=handler_dispatcher())
run_simple("localhost", 5000, router.wsgi())
What's Changed
* Indicate type support by bblommers in https://github.com/localstack/rolo/pull/10
* allow lists as return types for handler dispatchers by thrau in https://github.com/localstack/rolo/pull/11
* add method to create response from a static resource by thrau in https://github.com/localstack/rolo/pull/12
New Contributors
* bblommers made their first contribution in https://github.com/localstack/rolo/pull/10
**Full Changelog**: https://github.com/localstack/rolo/compare/v0.4.0...v0.5.0