Files
inventory-middleware/cmd/inv/main.go
T
2021-08-30 22:10:47 -05:00

45 lines
690 B
Go

package main
import (
"database/sql"
_ "encoding/json"
"fmt"
"net/http"
_ "github.com/lib/pq"
)
func main() {
http.HandleFunc("/data", get)
err := http.ListenAndServe(":8080", nil)
if err != nil {
panic(err)
}
}
func get(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusBadGateway)
w.Write([]byte("Hell world!"))
}
func sql_test() {
psqlInfo := fmt.Sprintf("host=%s port=%d user=%s password=%s dbname=%s sslmode=disable", "localhost", 5432, "postgres", "", "inventory")
db, err := sql.Open("postgres", psqlInfo)
if err != nil {
panic(err)
}
defer db.Close()
rows, err := db.Query("")
if err != nil {
panic(err)
}
defer rows.Close()
}