[BREAKING] Déplacer route /v4 vers /v4/health #12

Merged
vlbeaudoin merged 6 commits from breaking/v4-to-health into main 2023-06-02 03:20:13 -04:00
Showing only changes of commit 80a0260021 - Show all commits

View file

@ -7,6 +7,7 @@ import (
"git.agecem.com/agecem/bottin/v4/models" "git.agecem.com/agecem/bottin/v4/models"
_ "github.com/jackc/pgx/stdlib" _ "github.com/jackc/pgx/stdlib"
"github.com/jmoiron/sqlx" "github.com/jmoiron/sqlx"
"github.com/spf13/viper"
) )
// DataClient is a postgres client based on sqlx // DataClient is a postgres client based on sqlx
@ -24,6 +25,19 @@ type PostgresConnection struct {
SSL bool SSL bool
} }
func NewDataClientFromViper() (*DataClient, error) {
client, err := NewDataClient(
PostgresConnection{
User: viper.GetString("db.user"),
Password: viper.GetString("db.password"),
Host: viper.GetString("db.host"),
Database: viper.GetString("db.database"),
Port: viper.GetInt("db.port"),
})
return client, err
}
func NewDataClient(connection PostgresConnection) (*DataClient, error) { func NewDataClient(connection PostgresConnection) (*DataClient, error) {
client := &DataClient{PostgresConnection: connection} client := &DataClient{PostgresConnection: connection}