hyperioxx / frontman

Frontman is an open-source API gateway written in Go that allows you to manage your microservices and expose them as a single API endpoint. It acts as a reverse proxy and handles requests from clients, routing them to the appropriate backend service.
https://frontman-labs.github.io/frontman/
GNU General Public License v3.0
5 stars 0 forks source link

Optimize regex compilation by reusing compiled regex #101

Closed hyperioxx closed 1 year ago

hyperioxx commented 1 year ago

Currently, the regex is being compiled on every request in the ServeHTTP method. This is not efficient and can lead to performance issues. To improve performance, we should compile the regex once and reuse it for subsequent requests.

Proposed solution:

Compile the regex when the BackendService is created and store the compiled regex as a field in the BackendService struct. Update the ServeHTTP method to use the pre-compiled regex from the BackendService struct instead of recompiling it for each request.

This change will significantly improve performance by avoiding unnecessary regex compilations and will make the code more efficient overall.

hyperioxx commented 1 year ago

@amityahav @CCOLLOT