A lightning-fast, statically typed, and secure native RESTful Notes API built using the Go Standard Library and backed by a PostgreSQL database running inside a Docker container.
This project implements strict user isolation via JWT Authentication using a custom native HTTP Context Middleware.
- Zero Heavy Web Frameworks: Built entirely using Go's native
net/httpanddatabase/sqlpackages. - Strictly Typed Data: JSON payloads are decoded explicitly into Go structs to guarantee data integrity.
- Context-Driven Security: JWT validation is handled by a custom middleware that safely passes verified User IDs through Go's thread-safe Context API.
- Algorithm Confusion Defense: Strict HMAC algorithm verification during token parsing to prevent cryptographic downgrades.
- Language: Go 1.26+
- Database Driver:
github.com/lib/pq(Native PostgreSQL) - Authentication:
github.com/golang-jwt/jwt/v5&golang.org/x/crypto/bcrypt - Database: PostgreSQL 16 (Dockerized)
git clone https://github.com/chriscarias/notes-api-go.git
cd notes-api-goGo tracks dependencies in go.mod. Pull them down into your local cache:
go mod downloadCreate a .env file in the root directory:
Code snippet
DB_HOST=127.0.0.1
DB_PORT=5433
DB_NAME=notes_db
DB_USER=user
DB_PASS=password
JWT_SECRET=secret_key
go run .The compiler will spin up the native multithreaded server, listening at http://127.0.0.1:8002.