Just import a StreamRouter you need and declare the message handler in the same way as with a regular FastStream application.
When used in this way, FastStream does not use its own dependency system but integrates into FastAPI. That is, you can use Depends, BackgroundTasks and other original FastAPI features as if it were a regular HTTP endpoint, but you can't use faststream.Context and faststream.Depends.
Note that the code below uses fastapi.Depends, not faststream.Depends.
When processing a message from a broker, the entire message body is placed simultaneously in both the body and path request parameters. You can access them in any way convenient for you. The message header is placed in headers.
Also, this router can be fully used as an HttpRouter (of which it is the inheritor). So, you can use it to declare any get, post, put and other HTTP methods. For example, this is done at line 23.
If your ASGI server does not support installing state inside lifespan, you can disable this behavior as follows:
However, after that, you will not be able to access the broker from your application's state (but it is still available as the router.broker).
The FastStream application has the @after_startup hook, which allows you to perform operations with your message broker after the connection is established. This can be extremely convenient for managing your brokers' objects and/or sending messages. This hook is also available for your FastAPI StreamRouter