Skip to content

Project template for creating server rendered web applications in Go, with example database & content.

License

Notifications You must be signed in to change notification settings

bartvanbenthem/gofound-webapp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gofound-webapp

Project template for creating server side rendered web applications in Go, with example database & content.

  • Routing & middleware
  • HTTP session management
  • User registration & authentication
  • Database backend (SQL)
  • Templating & forms

Used packages

  • github.com/alexedwards/scs/mysqlstore
  • github.com/alexedwards/scs/v2
  • github.com/go-playground/form/v4
  • github.com/go-sql-driver/mysql
  • github.com/julienschmidt/httprouter
  • github.com/justinas/alice
  • github.com/justinas/nosurf
  • golang.org/x/crypto

Clone repo

git clone https://github.com/bartvanbenthem/gofound-webapp.git
cd gofound-webapp

Start MySQL Database

cd project
docker-compose up -d
cd ..

Build & start the WebServer

go test -vet=off -v ./cmd/web/

go build -o ./bin/gofoundweb ./cmd/web/

./bin/gofoundweb --addr=":4000" \
                 --dsn="web:pass@/gofound?parseTime=true" \
                 --smtp-host="localhost" \
                 --smtp-port="1025" \
                 --smtp-user="" \
                 --smtp-password="" \
                 --mail-address="mail@gofound.nl" \
                 --cert="./tls/cert.pem" \
                 --key="./tls/key.pem"

Test SendMail

Start MailHog to test mail capabillities

$ go get github.com/mailhog/MailHog
$ ~/go/bin/MailHog

Test login

Use the provisioned user:

create self signed certificates

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