Our great sponsors
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
-
fresh
Build and (re)start go web apps after saving/creating/deleting source files. (by gravityblast)
-
fasthttp
Fast HTTP package for Go. Tuned for high performance. Zero memory allocations in hot paths. Up to 10x faster than net/http
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
Fiber is an Express inspired web framework built on top of Fasthttp, the fastest HTTP engine for Go. Make sure to use Fiber v2. Fiber V2 has a lot of breaking changes to Fiber v1. I had to spend an extra hour just upgrading these breaking changes cause I started with v1.
Some added advantages of using Fiber is it's logging module. If you're on v1, you would need to install the logger package separately, but in v2 it has been made available within v2 itself: "github.com/gofiber/fiber/v2/middleware/logger".
Needed a more robust way, which is provided by this package called fresh. Fresh is a command line tool that builds and (re)starts your web application everytime you save a Go or template file. You can also customise the log color that comes with the default fresh setup. It requires a default runner.conf file. If you want to go with the default options, you don't even need this file on your project root.
Next, we need our web service to talk to our web-service. There are quite a few ODM(Object Document Mapper) out there. But given my initial requirement was pretty straightforward, I went the default mongodb golang driver. It's pretty straightforward to connect an mongodb client:
I went with fasthttp, which provides high performance, zero memory allocations in hot paths and Up to 10x faster than net/http for a large throughput service. Go provides out of the box http support but for a beginner, it felt much easier to go with a framework, thereby ended up using fiber.