Skip to content
Snippets Groups Projects
Commit 507791b3 authored by Simon Lindblad's avatar Simon Lindblad
Browse files

Refactor database configuration

parent 74ce58e0
Branches implement-api
No related tags found
No related merge requests found
...@@ -12,6 +12,11 @@ import ( ...@@ -12,6 +12,11 @@ import (
"strings" "strings"
) )
const (
postgresUser = "simon"
postgresHost = "localhost"
)
type Task struct { type Task struct {
Id int Id int
Name string Name string
...@@ -145,8 +150,7 @@ func (db *Database) taskHandler(w http.ResponseWriter, r *http.Request) { ...@@ -145,8 +150,7 @@ func (db *Database) taskHandler(w http.ResponseWriter, r *http.Request) {
} }
func ConnectDb() *sql.DB { func ConnectDb() *sql.DB {
// TODO: Refactor the database config db, err := sql.Open("postgres", fmt.Sprintf("postgres://%s@%s/todo?sslmode=disable", postgresUser, postgresHost))
db, err := sql.Open("postgres", "postgres://simon@localhost/todo?sslmode=disable")
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment