kord icon indicating copy to clipboard operation
kord copied to clipboard

Discord proxy and more gradual request control

Open WinteryFox opened this issue 3 years ago • 0 comments

Hi friendly Kord contributors,

I would like to use a proxy between my Kord rest instance and the Discord rest endpoints, this proxy will be handling rate limits as well. I've noticed that there is currently no no-op rate limit handler either. In my quest to use a proxy I decided to "implement" my own RequestHandler, to do this I was going to copy the current default RequestHandler implementation and modify it to fit my needs, make it use another URL than the Discord base URL as well as add headers per request basis (requests will need to send a token that will vary through the lifetime of the application in the headers, as well as some other headers I need to add.) Upon attempting this however I discovered another issue with this method, in that the optional serializer for the KtorRequestException class is marked as internal (https://github.com/kordlib/kord/blob/bc0e76b93284564e693aa00e9c2acfbf8de61e66/rest/src/main/kotlin/route/Route.kt#L40), and thus cannot be used by any custom implementations of the RequestHandler, even if they also use ktor.

Here's an outline of the things I'd like to see added/changed

  • Add support for proxies
  • Add some way to change the Request before it's actually executed in whatever RequestHandler (e.g. adding/changing headers)
  • Mark the optional serializer as public for KtorRequestException to allow other RequestHandler implementations that also make use of ktor to use this already existing model.

Cheers, Amy.

WinteryFox avatar Mar 02 '22 20:03 WinteryFox