Rolo

Latest version: v0.7.3

Safety actively analyzes 681775 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

0.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 https://github.com/localstack/rolo/pull/15
* fix pydantic return type serializer to support lists by thrau in https://github.com/localstack/rolo/pull/17
* refactor routing code into `rolo.routing` package by thrau in https://github.com/localstack/rolo/pull/18
* fix pydantic type hint check by thrau in https://github.com/localstack/rolo/pull/20
* add json-rpc server tutorial to docs by thrau in https://github.com/localstack/rolo/pull/16


**Full Changelog**: https://github.com/localstack/rolo/compare/v0.6.0...v0.7.0

0.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:

python
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:

python
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 https://github.com/localstack/rolo/pull/14
* fix restore payload by bentsku in https://github.com/localstack/rolo/pull/13

New Contributors
* bentsku made their first contribution in https://github.com/localstack/rolo/pull/13

**Full Changelog**: https://github.com/localstack/rolo/compare/v0.5.0...v0.6.0

0.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:

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

0.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
* Switch to pyproject.toml by silv-io in https://github.com/localstack/rolo/pull/5
* make Router.add thread safe by thrau in https://github.com/localstack/rolo/pull/6

New Contributors
* silv-io made their first contribution in https://github.com/localstack/rolo/pull/5

**Full Changelog**: https://github.com/localstack/rolo/compare/v0.2.0...v0.3.0

0.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 https://github.com/localstack/rolo/pull/3
* add ruff config and fix linter errors by thrau in https://github.com/localstack/rolo/pull/4

**Full Changelog**: https://github.com/localstack/rolo/compare/v0.1.0...v0.2.0

0.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

Links

Releases

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.