December Adventure 2024
I want to use the Zig programming language for quite some time now. Did some ziglings and read some documentation, but never program something useful. I want to change this on this december adventure by programming a gemini application.
Zig Programming language
ziglings
So, what's the plan? First thing will be refreshing the basics of the language by doing some ziglings. When I feel confident enough, I will start working on the basics of the gemini application, which might be reading through the Gemini specification and finding a suitable gemini server with CGI support. After that, I want to build some basic request/response and deliver a basic string. If that works, I can continue building the actual application.
The application should help maintain a simple "server log". Like a simple gemlog, it contain a list of entries, order by date, which describe some action, taken on the server. We maintain this for the økoyono server manually, but lost some interest in it. Adding new entries should be therefore simple and easy, straight from the gemini browser. Authentication should be done with a client certificate whitelist. The data should be stored directly into the file itself, so no separate database is needed.
It's not a complex application, but it has a real usecase and if I finish it ealy in december, I can always add more features or change plans.
Gemini Application Developer Guide
RFC: TinyLogs format
twins Gemini Server
Day 1
I want to have something useful as soon as possible. So I've created a simple docker compose file which will spin up a twins server with a FastCGI configuration attached to a newly created zig project. This works as intended, so I can continue working on the actual server. For that, I've started reading through both of the following articles and the zig test file for http itself.
Building a HTTP server in zig
TCP server in zig
http.zig test file
With that, I've just copy/pated some code, so I have someting to test on. Tomorrow, I will go into the code and try to build some simple request. 30 minutes are not long, so I keep focusing on one part only, not worry about 1000 other little things, which need to be addressed along the way. One step at a time.
Git repository for my #decemberAdventure
Day 2
Did not get any real programming done today. I've created a self signed SSL certificate, so I can test the gemini server and the FastCGI integration. Turns out, the FastCGI protocol is much more complicated as I initially thought. So I've searched the twins gemini server source code how to integrate my zig program more easily. There is a "command" type, which can be used to execure applications. This might be the simpler way to integrate a zig application into the gemini server. Next step will be write some simple bash script to test the command type.
serve_command.go from twins gemini server
Day 3
Not much done today on the #decemberadventure, had a long work day and a lot of other stuff to do, which keept me busy the whole day. But I wanted to do a little test with a bash script to test the command type. Turns out, it's really simple and works as expected.