diff --git a/api.go b/api.go index 24ec9c1..a6197b8 100644 --- a/api.go +++ b/api.go @@ -32,7 +32,7 @@ func apiRouter() http.Handler { } func getTransactions(w http.ResponseWriter, req *http.Request) { - db, err := sqlx.Connect("postgres", "user=rcntuser password=Devel@pmentPa$$w0rd host=10.0.0.183 dbname=Borealis sslmode=disable") + db, err := sqlx.Connect("postgres", DB_CONNECTION_STRING) if err != nil { log.Fatal(err) } diff --git a/main.go b/main.go index 9494fc1..bdc9a7f 100644 --- a/main.go +++ b/main.go @@ -5,6 +5,7 @@ import ( "net/http" "fmt" + "flag" "log" "time" @@ -13,6 +14,8 @@ import ( "github.com/go-chi/chi/v5/middleware" ) +var DB_CONNECTION_STRING string = "user=rcntuser password=Devel@pmentPa$$w0rd host=10.0.0.183 dbname=Borealis sslmode=disable" + // "json:"json_code_name,omitempty"" (omit empty) // if you use `json:"-"` it doesn't encode it type Transaction struct { @@ -40,31 +43,13 @@ func main() { log.SetPrefix("RecountServer: ") log.SetFlags(0) - /* - jsonExample := `{ - "Id": 3, - "Amount": "100", - "Description": { - "String": "Transaction 3", - "Valid": true - }, - "Account": 1, - "Bucket": { - "Int64": 1, - "Valid": true - }, - "TransactionDate": "2023-11-11T00:00:00Z" - }` + var nFlag = flag.Bool("d", false, "whether to enable debug mode") + flag.Parse() - var trns Transaction = Transaction{} - err = json.Unmarshal([]byte(jsonExample), &trns) - - if err != nil { - log.Println(err) - } else { - log.Println(trns.Amount) + if *nFlag { + log.Println("Is debugging") } - */ + r := chi.NewRouter() // A good base middleware stack diff --git a/tests/source_file.sqlite3 b/tests/source_file.sqlite3 new file mode 100644 index 0000000..e69de29