Skip to content

Releases: localstack/rolo

v0.7.0

24 Jul 10:59
Compare
Choose a tag to compare

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

19 Jul 10:40
Compare
Choose a tag to compare

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

21 Apr 12:44
Compare
Choose a tag to compare

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

Full Changelog: v0.4.0...v0.5.0

v0.3.0

26 Jan 18:33
d9f27a4
Compare
Choose a tag to compare

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

22 Jan 13:16
Compare
Choose a tag to compare

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

19 Jan 14:31
Compare
Choose a tag to compare

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