small main code improve
This commit is contained in:
parent
83315c027a
commit
00621524e9
42
main.go
42
main.go
@ -9,7 +9,9 @@ import (
|
|||||||
"backend/src/repo"
|
"backend/src/repo"
|
||||||
"backend/src/services"
|
"backend/src/services"
|
||||||
"backend/src/utils"
|
"backend/src/utils"
|
||||||
|
"crypto/rsa"
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
|
"database/sql"
|
||||||
"encoding/pem"
|
"encoding/pem"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
@ -30,26 +32,32 @@ func main() {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
keyRawBytes, err := os.ReadFile(conf.GetJwtSigningKey())
|
var key *rsa.PrivateKey
|
||||||
if err != nil {
|
{
|
||||||
panic(err)
|
keyRawBytes, err := os.ReadFile(conf.GetJwtSigningKey())
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
keyPem, _ := pem.Decode(keyRawBytes)
|
||||||
|
key, err = x509.ParsePKCS1PrivateKey(keyPem.Bytes)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
keyPem, _ := pem.Decode(keyRawBytes)
|
var sqlDb *sql.DB
|
||||||
key, err := x509.ParsePKCS1PrivateKey(keyPem.Bytes)
|
{
|
||||||
if err != nil {
|
pgConnStr := conf.GetPostgresUrl()
|
||||||
panic(err)
|
connConf, err := pgx.ParseConnectionString(pgConnStr)
|
||||||
}
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
pgConnStr := conf.GetPostgresUrl()
|
sqlDb := stdlib.OpenDB(connConf)
|
||||||
connConf, err := pgx.ParseConnectionString(pgConnStr)
|
if err := sqlDb.Ping(); err != nil {
|
||||||
if err != nil {
|
panic(err)
|
||||||
panic(err)
|
}
|
||||||
}
|
|
||||||
|
|
||||||
sqlDb := stdlib.OpenDB(connConf)
|
|
||||||
if err := sqlDb.Ping(); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
jwtUtil := utils.NewJwtUtil(key)
|
jwtUtil := utils.NewJwtUtil(key)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user