package main import ( "context" "log" "net/http" "github.com/babariviere/short/internal/api" "github.com/babariviere/short/internal/db" "github.com/babariviere/short/internal/oas" "github.com/jackc/pgx/v5" ) func main() { psql, err := pgx.Connect(context.Background(), "postgres://short:short@localhost:5432/short") if err != nil { log.Fatalf("cannot connect to database: %v", err) } queries := db.New(psql) handler := api.NewHandler(queries) srv, err := oas.NewServer(handler) if err != nil { log.Fatalf("failed te create OpenAPI server: %v", err) } log.Println("Listening on :8080") if err = http.ListenAndServe(":8080", srv); err != nil { log.Fatal(err) } }