WP 1: Golinks
This project is a very simple webapp inspired by Google's internal “go” system. First time I came to know about this was from this Gitlab thread. Also from the same thread I came to know about an open-source implementation of it at kellegous/go.
I have been working with Golang extensively at work and otherwise for the past year but this is my first web application in Go. The application is analogous to a URL shortner with the different that you get to choose the slug. It implements the functionality of adding and deleting as well as listing all links. I also semi-implemented authentication where it assumes an external system (middleware) to do it and set a specific HTTP header. I am using Cloudflare Access for implementing this in my current setup.
I used Mux router to build the endpoints with two middlewares for logging and authentication. For logging, I used a leveled logging library by Netflix engineer called zerolog. I used Go implementation of LevelDB which is an embedded key-value store, for storing the data. For webpages, I used the standard library html/template package.
I encountered an issue when I tried to truely make it like original go links. In the original design, one can just type
go/<name> in the address bar of the browser and will be redirected to the destination however this requires adding the root domain as part of search domains in network settings. But, as mentioned above I am using Cloudflare as a proxy in front of my server so it terminates the SSL at proxy level and there is no public certificate that I can get for
go/ base URL so I couldn't do it. Thankfully I found a hack around it in Chrome settings. In Chrome, one can add a custom search enginer by going to
chrome://settings/searchEngine. Once added with a keyword, Chrome understands it as a search enginer. What this means in practise is that one can type keyword and press space and the subsequent text will be substituted to the given URL's search string.