go-sample-webpage/main.go
kekskurse e887a5e9b8
Some checks failed
continuous-integration/drone/push Build is failing
mysql for user
2021-11-23 21:32:55 +01:00

46 lines
1.2 KiB
Go

package main
import (
"crypto/tls"
"embed"
"git.keks.cloud/kekskurse/go-sample-webpage/pkg/sample"
"git.keks.cloud/kekskurse/go-sample-webpage/pkg/user"
"git.keks.cloud/kekskurse/go-sample-webpage/pkg/webpage"
"github.com/go-chi/chi/v5"
"github.com/go-chi/jwtauth/v5"
"github.com/jmoiron/sqlx"
gomail "gopkg.in/mail.v2"
)
// content holds our static web server content.
//go:embed static/* templates/*
var webserver embed.FS
//go:embed database/migrations/*.sql
var migrationFS embed.FS
func main() {
config := webpage.WebPageConfig{
Templates: webserver,
Static: webserver,
Migrations: migrationFS,
Bootstrap: func(router chi.Router) {
tokenAuth := jwtauth.New("HS256", []byte("secret"), nil)
db, err := sqlx.Open("mysql", "root:test@tcp(localhost:3306)/test?multiStatements=true")
if err != nil {
panic(err)
}
uc := user.NewUserClientSql(db)
d := gomail.NewDialer("localhost", 1025, "from@gmail.com", "email_password")
d.TLSConfig = &tls.Config{InsecureSkipVerify: true}
userconfig := user.NewUserConfig()
sample.Register(router)
user.Register(router, tokenAuth, uc, d, userconfig)
},
}
webpage.RunWebApp(config)
}