Simple Go & Bootstrap web gallery for ArtesaniaSory.
Examples for compilation or execution.
go build ./cmd/web/
./web
- Port: Specifie the port to listen
./web -port="4000"
- DSN: Specifie the PostgreSQL Database URL
./web -db-dsn="postgres://user:password@pg_server/db_name"
# by default this take the ENV Var DATABASE_URL
You can pass an OS ENV Var in the -db-dns
flag like:
./web -db-dsn=$DATABASE_URL
- Custom middlewares for basic security, request logging and recovery from Panic!.
- Http router (httprouter).
- File Server for static files.
- Embed files to the binary (static and templates).
- Template cache to memory.
- PostgreSQL Database (pgx).
- SessionManager with session storage to PostgreSQL (scs).
- Flags usage for custom setup
- Middleware manager (alice).
- Custom loggers for info and error
- Database Migrations (migrate)
- Graceful Shutdown
- JSON logs
- Query Timeout Context on each DB Request
- DB Connection pool configuration
- Create a migration:
migrate create -seq -ext=.sql -dir=./migrations create_categories_table
- Execute UP migrations
NOTE: in both cases, the sslmode
querystring is optional.
migrate -path=./migrations -database="postgres://user:pass@db_server/db_name?sslmode=disable" up
- Execute down migrations
migrate -path=./migrations -database="postgres://user:pass@db_server/db_name?sslmode=disable" down
- See migration version
migrate -path=./migrations -database="postgres://user:pass@db_server/db_name?sslmode=disable" version
- Go to specific version (migration 1 in this case)
migrate -path=./migrations -database="postgres://user:pass@db_server/db_name?sslmode=disable" goto 1