A simple web application built while following the Let's Go book by Alex Edwards. This project is designed to help you get familiar with building web servers in Go, covering key concepts such as routing, templating, database interaction, authentication and authorization, HTTPS, and testing using Go's standard library.
-
Slog package is used to add structured logging.
-
Command-line flags are used to manage configuration settings.
go run ./cmd/web -addr=":80"
-
Dynamic HTML templates with html/template. In-memory caching is used to read and parse the relevant template files only once.
-
Content-Security-Policy headers are set to prevent a variety of cross-site scripting, clickjacking, and other code-injection attacks.
-
The session manager alexedwards/scs was considered as its allows to store session data server-side and comparing to gorilla/sessions it was a better choice due to the ability to renew session IDs.
-
justinas/nosurf is used to mitigate the risk of CSRF
-
justinas/alice package is used to manage middleware/handler chains and make them composable.