Maciej Główka
Blog Games Contact

← Return to Blog Index

Sept. 18, 2022

Making Axum server to listen over a Unix socket


I have recently been doing some tinkering with the Axum framework, making simple REST backends. When I was ready to push one of them to the public server, I have realized that my hosting provider uses unix sockets to communicate custom apps with the outside world.

The app would receive standard HTTP packets, but had to listen on unix instead of TCP (a bit similar to how Docker API works). At first I was worried that I will have to change my chosen framework completely, as I couldn't find such an option in Axum. But then I remembered that, when I was extracting some info from the Docker system within Rust, I have used a small Hyperlocal crate. It allows for simple unix socket binding in Rust. And as it is build over Hyper (as Axum is) I thought that it is possible that they would talk together nicely.

In the end, the code needed very little change and it seems that the two socket types can be used quite interchangeably.

← OBJ with MTL and textures from THREE.js Text-based (JSON, Toml) resources in Bevy engine→