Great news! Now **Propan** can be used as a full part of **FastAPI**!
python
from fastapi import FastAPI
from propan.fastapi import RabbitRouter
app = FastAPI()
router = RabbitRouter("amqp://guest:guestlocalhost:5672")
router.event("test")
async def hello(m: dict) -> dict:
return { "response": "Hello Propan!" }
app.include_router(router)
You can find a complete example in [documentation](../5_integrations/2_fastapi-plugin)
Also, added the ability to [test](../2_getting_started/7_testing) your application without running external dependencies as a broker (for now only for RabbitMQ)!
python
from propan import RabbitBroker
from propan.test import TestRabbitBroker
broker = RabbitBroker()
broker.handler("ping")
async def healthcheck(msg: str) -> str:
return "pong"
def test_publish():
async with TestRabbitBroker(broker) as test_broker:
await test_broker.start()
r = await test_broker.publish("ping", queue="ping", callback=True)
assert r == "pong"
Also added support for [RPC over MQ](../2_getting_started/4_broker/5_rpc) (RabbitMQ only for now): `return` of your handler function will be sent in response to a message if a response is expected.
<h3>Breaking changes:</h3>
* Brokers `publish_message` method has been renamed to `publish`
* removed `declare` argument in `RabbitQueue` and `RabbitExchange` - now you need to use `passive`