added debug mode
This commit is contained in:
parent
8342a8f5f4
commit
c16ffe3a2e
3 changed files with 9 additions and 24 deletions
2
api.go
2
api.go
|
@ -32,7 +32,7 @@ func apiRouter() http.Handler {
|
||||||
}
|
}
|
||||||
|
|
||||||
func getTransactions(w http.ResponseWriter, req *http.Request) {
|
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 {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
31
main.go
31
main.go
|
@ -5,6 +5,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"flag"
|
||||||
"log"
|
"log"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -13,6 +14,8 @@ import (
|
||||||
"github.com/go-chi/chi/v5/middleware"
|
"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)
|
// "json:"json_code_name,omitempty"" (omit empty)
|
||||||
// if you use `json:"-"` it doesn't encode it
|
// if you use `json:"-"` it doesn't encode it
|
||||||
type Transaction struct {
|
type Transaction struct {
|
||||||
|
@ -40,31 +43,13 @@ func main() {
|
||||||
log.SetPrefix("RecountServer: ")
|
log.SetPrefix("RecountServer: ")
|
||||||
log.SetFlags(0)
|
log.SetFlags(0)
|
||||||
|
|
||||||
/*
|
var nFlag = flag.Bool("d", false, "whether to enable debug mode")
|
||||||
jsonExample := `{
|
flag.Parse()
|
||||||
"Id": 3,
|
|
||||||
"Amount": "100",
|
|
||||||
"Description": {
|
|
||||||
"String": "Transaction 3",
|
|
||||||
"Valid": true
|
|
||||||
},
|
|
||||||
"Account": 1,
|
|
||||||
"Bucket": {
|
|
||||||
"Int64": 1,
|
|
||||||
"Valid": true
|
|
||||||
},
|
|
||||||
"TransactionDate": "2023-11-11T00:00:00Z"
|
|
||||||
}`
|
|
||||||
|
|
||||||
var trns Transaction = Transaction{}
|
if *nFlag {
|
||||||
err = json.Unmarshal([]byte(jsonExample), &trns)
|
log.Println("Is debugging")
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
log.Println(err)
|
|
||||||
} else {
|
|
||||||
log.Println(trns.Amount)
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
r := chi.NewRouter()
|
r := chi.NewRouter()
|
||||||
|
|
||||||
// A good base middleware stack
|
// A good base middleware stack
|
||||||
|
|
0
tests/source_file.sqlite3
Normal file
0
tests/source_file.sqlite3
Normal file
Loading…
Reference in a new issue