some cleanup
This commit is contained in:
@@ -3,8 +3,11 @@ package config
|
||||
import (
|
||||
"github.com/adrg/xdg"
|
||||
"github.com/pelletier/go-toml"
|
||||
"net"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
var confPath string
|
||||
@@ -18,7 +21,7 @@ func init() {
|
||||
Server: Server{
|
||||
Host: "127.0.0.1",
|
||||
Port: 8080,
|
||||
FrontendUrls: []string{"http://localhost:5173"},
|
||||
FrontendUrls: []string{"http://localhost:5173", "http://127.0.0.1:5173"},
|
||||
},
|
||||
Database: Database{
|
||||
User: "pp",
|
||||
@@ -75,6 +78,17 @@ type Database struct {
|
||||
Name string
|
||||
}
|
||||
|
||||
// URL returns the Postgres connection URL. The local dev database has no SSL.
|
||||
func (d Database) URL() *url.URL {
|
||||
return &url.URL{
|
||||
Scheme: "postgres",
|
||||
User: url.UserPassword(d.User, d.Password),
|
||||
Host: net.JoinHostPort(d.Host, strconv.Itoa(d.Port)),
|
||||
Path: "/" + d.Name,
|
||||
RawQuery: "sslmode=disable",
|
||||
}
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
Server Server
|
||||
Database Database
|
||||
|
||||
Reference in New Issue
Block a user