apimorphism / telegramium

Telegramium or F[ Tg ] - pure functional Telegram Bot API implementation for Scala.
MIT License
81 stars 9 forks source link

Provide a way to pass extra routes to the WebhookBot server #477

Closed lolgab closed 6 months ago

lolgab commented 7 months ago

I have an application which exposes a Telegram bot but also another HTTP server which serves a plain old website. I want to serve my own routes together with Telegramium routes in the server. To do that I created my own copy of WebhookBot where I added a new parameter: fallback: HttpRoutes[F] and then when I use routes, I do .withHttpApp(routes().combineK(fallback).orNotFound).

It would be nice if Telegramium supported this.

johnspade commented 6 months ago

In general I wouldn't recommend such a setup, Telegramium's http4s server settings may not be suitable for the application, and it's implementation details. I thought about making the WebhookBot routes public so users can use them with their server, but Telegramium needs to control a number of server settings such as SSL and error handling. The suggested way is to run the application server and the Telegramium server on different ports. While it may be easier to run all routes on the same server in a simple case, usually the application needs to be able to create and configure its own http4s (or other) server.

Feel free to reopen or comment if you have more questions or suggestions.