Releases: localstack/rolo
v0.7.0
Summary
This release mostly brings code re-organization and a bugfix for the pydantic integration release with v0.6.0.
We also added docs and a tutorial for the handler chain, check out https://rolo.localstack.cloud!
What's Changed
- add sphinx docs by @thrau in #15
- fix pydantic return type serializer to support lists by @thrau in #17
- refactor routing code into
rolo.routing
package by @thrau in #18 - fix pydantic type hint check by @thrau in #20
- add json-rpc server tutorial to docs by @thrau in #16
Full Changelog: v0.6.0...v0.7.0
v0.6.0
Summary
This release adds support for Pydantic when using the handler dispatcher, similar to what you are used to from FastAPI.
Here is an example:
class MyItem(pydantic.BaseModel):
name: str
price: float
is_offer: bool = None
@route("/items/<item_id>", methods=["POST"])
def add_item(request: Request, item_id: int, item: MyItem) -> str:
print(item.name, item.price)
return "ok"
@route("/items/<item_id>", methods=["GET"])
def get_item(request: Request, item_id: int) -> MyItem:
return MyItem(name="rolo", price=4.20)
You can also use the @resource
decorator on classes to organize your code:
router = Router(dispatcher=handler_dispatcher())
@resource("/items/<int:item_id>")
class MyResource:
def on_get(self, request: Request, item_id: int):
return MyItem(name="rolo", price=420.69)
def on_post(self, request: Request, item_id: int, item: MyItem):
return {"item_id": item_id, "item": item.model_dump()}
router.add(MyResource())
What's Changed
- add support for pydantic in the handler dispatcher by @thrau in #14
- fix restore payload by @bentsku in #13
New Contributors
Full Changelog: v0.5.0...v0.6.0
v0.5.0
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:
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:
@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()
.
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 #10
- allow lists as return types for handler dispatchers by @thrau in #11
- add method to create response from a static resource by @thrau in #12
New Contributors
- @bblommers made their first contribution in #10
Full Changelog: v0.4.0...v0.5.0
v0.3.0
Quick release to fix a concurrency issue in Router
. Also, this release switches completely to pyproject.toml, thanks to @silv-io!
What's Changed
New Contributors
Full Changelog: v0.2.0...v0.3.0
v0.2.0
Gateway & Handler chain migration
With 0.2.0, we migrated the Gateway
and HandlerChain
concepts from localstack into rolo. Part of that is a generalization and removal of AWS concepts. The RequestContext
is now a flexible data container where arbitrary data can be stored through setting attributes context.service = ...
.
This release also adds the necessary constructs to serve a Gateway
as a WSGI or ASGI application.
What's Changed
- import gateway and handler chain code from localstack/localstack by @thrau in #3
- add ruff config and fix linter errors by @thrau in #4
Full Changelog: v0.1.0...v0.2.0
v0.1.0
Hello World!
We're releasing our HTTP framework used in localstack as a standalone project, Rolo HTTP. This is the first iteration that includes the core utilties we built around Werkzeug and Hypercorn.
Full Changelog: https://github.com/localstack/rolo/commits/v0.1.0