How to write complex HTTP middlewares in Go

Lot of the tutorials on the Web show different ways of writing Go HTTP middlewares, but most of them use functional approach meaning using functions that get dependencies as parameters and return HTTP handler function or handler. There is nothing wrong about this, but it can be quite messy to write a complex middlewares like database based authentication and authorization or simply middlewares which have lot of dependencies. In this article I am going to explain how to use more object oriented way of writing such middlewares....

2022-11-13 · 4 min · Boban Acimovic

Build Rust container images faster using layer caching

In the previous blog post I described how to define GitHub Actions pipeline to benefit from caching Rust dependencies and container images’ layers. But the final result may also depend on your Dockerfile. Namely, Docker Buildx Action supports BuildKit and buildx and in order to benefit from this, your Dockerfile has to explicitly cache layers. Actually, this is quite easy to achieve, let’s see the example: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 # syntax=docker/dockerfile:1....

2022-06-03 · 2 min · Boban Acimovic

How I speeded up my Rust builds on GitHub ~30 times

Rust is a great programming language, but it’s compiler is known to be slow. The main reason is that it checks so many things during the compilation in order to provides memory and concurrency safety. Like in many other cases, pipelines may be speeded up by caching, but it is very important to set the caching properly, otherwise it won’t help. Besides compiling your code may be slow, you also may want to use some cargo tools to lint and check your code and this will require to be compiled as well, if you don’t want to download binaries....

2022-05-18 · 5 min · Boban Acimovic

How to fix possible missing firmware warning during kernel update on Linux Mint

If you are running default kernel with your Ubuntu or Linux Mint installation, you probably won’t face this problem during kernel updates because all packages are coming from the official distribution sources. However, if you like to run the newest Linux kernels and update them using mainline kernel installer, you may get warning possible missing firmware during the installation. Few days ago I got this warning on my Linux Mint 20....

2022-05-18 · 2 min · Boban Acimovic

Custom Go HTTP handlers using generics

Few days ago Go 1.18beta1 was released and with it the first official generics support. I was embarrassed with standard Go’s HTTP handler functions for quite a while. If you are not familiar with Go, you probably wonder why, but if you are familiar, I believe you know. For example, implementing a RESTful API using idiomatic Go requires lot of code repetition in order to JSON decode request bodies and JSON encode response bodies....

2021-12-19 · 4 min · Boban Acimovic