Categorygithub.com/jfilipedias/snippetbox
module
0.0.0-20241130211453-e7c301030ad1
Repository: https://github.com/jfilipedias/snippetbox.git
Documentation: pkg.go.dev

# README

Snippetbox

An image of application home page This project is an MVC web application built with Go 1.23. It was developed following the Let's Go book by Alex Edwards. It implements the following concepts:

  • Configuration management
  • Logging and error handling
  • SQL Database connection
  • HTML templating
  • Middlewares
  • Form Validation
  • Server session management
  • Authentication and authorization
  • Secutiry concerns
  • Testing

Getting started

Setup the HTTPS connection

To run the server with a local HTTPS connection, a TLS certificate is required. To get a certificate for development environment you can use the crypt/tls Go package. It includes the generate_cert.go tool, wich generates a self-signed certificate. To use this tool, run the following commands:

$ mkdir tls
$ cd tls
$ go run /usr/local/go/src/crypto/tls/generate_cert.go --rsa-bits=2048 --host=localhost

Setup the database container

The web app uses a MySQL database to persist user data. You can set up a Docker container running a MySQL image with a clean database using the following command:

$ docker compose up -d

The database schema will be set up by the init.sql script. It creates the database tables and seeds them with initial data. It also creates a separate database and user to run the integration test without any side effects on the main database.

Run the project

Execute the following command:

$ go run ./cmd/web

Dependencies

# Packages

No description provided by the author
No description provided by the author