Writing a proxy in Rust and why it is the language of the future

Terry Raimondo
The Startup
Published in
4 min readJun 22, 2019

--

It’s been a year since I wrote a little proxy with Rust, it is one of my first projects with this language and I learned a lot writing it. To sum up a bit, the main goal of this proxy is to be really simple to use and easy to extend with middlewares. It targets HTTP APIs and can be used in front of a lot of services. This proxy has been used in multiple projects, with microservices architecture and so on…

Why this proxy ?

As said earlier, we are working on a micro-services architecture. The first thing I needed was an authentication mechanism, we chose to use JWTs and added a service to generate and sign those. As I wanted to avoid asking this service if the provided token had the right signature for each request, I had to find another solution, what about a proxy ? It would also allow us to route our requests to the right services, log the requests, add CORS and so on…

The real deal here is that I can forget it once set up, it is not coupled with other services and is really light.

It is based on hyper, a solid and async HTTP library. I know my implementation may not be the most efficient, but it works, it is light, easy to use and extend, and my goal was not to write the perfect piece of software but something fitting my evolving needs. It has not the pretension of being a real fatass proxy like sozu.

How to use it:

--

--