Create A Golang Web Server with Proper Graceful Shutdown From Scratch



Create A Golang Web Server with Proper Graceful Shutdown From Scratch

Create A Golang Web Server with Proper Graceful Shutdown From Scratch

Learn to make your own web server in Golang. This coding walk-through will show you how to make your own web server with a proper graceful shutdown sequence.

If you want to make a simple web service without a ton of bloat, Golang is a super lightweight solution. This tutorial starts from scratch and explains how to create a web server using the httprouter Go package. As an added bonus, I explain the importance of having your server gracefully shut down to avoid disruption to your users.

This is part one of a series that will build a full REST API microservice in Go with an automated build process and fully deployable Helm chart for Kubernetes. Subscribe so you get notified when I post the next part of the series!

Source code (branch for this part of the series): https://github.com/askcloudarchitech/go-rest-api-kubernetes-example/tree/basic-webserver
Full Code: https://github.com/askcloudarchitech/go-rest-api-kubernetes-example
httprouter package: https://pkg.go.dev/github.com/julienschmidt/httprouter
My website: https://askcloudarchitech.com

00:00 – intro
00:12 – Create and clone your repo
00:45 – Initialize a Go Module
01:00 – Create the necessary files
01:18 – Scaffolding for the basic webserver
05:59 – Adding a response to the handler
06:35 – Adding a graceful shutdown process
10:20 – Startup and shutdown demonstration

Comments are closed.