-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
32 lines (26 loc) · 638 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package main
import (
"database/sql"
"fmt"
"github.com/ehsundar/scaffold/internal/api"
"github.com/ehsundar/scaffold/internal/storage"
"github.com/gorilla/mux"
_ "github.com/lib/pq"
"net/http"
)
func main() {
psqlconn := fmt.Sprintf("host=localhost port=5432 user=postgres password=mysecretpassword dbname=scaffold sslmode=disable")
db, err := sql.Open("postgres", psqlconn)
err = db.Ping()
if err != nil {
panic(err)
}
s := storage.NewPostgresStorage(db)
scaffold := api.NewScaffold(s)
r := mux.NewRouter()
api.RegisterRoutes(r, scaffold)
err = http.ListenAndServe(":8080", r)
if err != nil {
panic(err)
}
}