This repo contains an example of a simple asynchronous http server written in rust using tokio and warp framework. In order to run the server you only need docker and docker-compose.
There are separate dockerfiles for development and production mode since they have different workflow and requirements.
This project uses ffi bindings to stb C library and has quite a bit of unsafe rust code.
Development mode uses cargo-watch, recompiling files when they are saved inside a container.
docker-compose -f docker-compose.yml -f docker-compose-dev.yml upProduction mode image is using multistage docker building technique, reducing the size of final image.
docker-compose -f docker-compose.yml upThe server starts at localhost:3000 and has just one method /upload_image, which accepts post requests with either multipart/form-data encoded files, or a json array, containing base64-encoded images:
[
{
"filename": "pic.png",
"data": "iVBORw0..."
}
]The server also serves images at /img, and static page at /images. The better way to do this is by using separate container (for example nginx) for serving static files and reverse-proxying api requests to this server.
There are no kinds of automated tests here, instead go at / to send a request, go at
/images to see uploaded images.