For a more mature implementation of this concept, I would highly recommend having a look at Kore: https://kore.io
It has a sane architecture, and is fully privilege separated by default, with private keys isolated in a separate process. I've been using it lately to write REST APIs in C, and the experience has been awesome, it has great APIs to parse requests and easily construct responses.