Refactor and rename storage to Json

This commit is contained in:
2023-02-08 18:33:44 +00:00
parent 6aebdc8b5e
commit 38a200c648
5 changed files with 90 additions and 66 deletions

View File

@@ -15,15 +15,13 @@ import (
// main is the entry point of the application
func main() {
var (
dataPath = "data/heros.json" // store to JSON file
dataPath = "data/heros.json" // Path to read superheros from JSON file
port = 8080 // Port to serve
key = 5 // DeeSee encryption key
err error
key = 5 // Json encryption key
logger = log.Default() // Logger
err error // Error
)
// Create logger
logger := log.Default()
// Get port from environment variable
if os.Getenv("PORT") != "" {
port, err = strconv.Atoi(os.Getenv("PORT"))
@@ -54,8 +52,8 @@ func main() {
logger.Fatalf("Invalid data path: %s", dataPath)
}
// Create DeeSee storage
s, err := storage.New(dataPath)
// Create Json storage
s, err := storage.NewJson(dataPath)
if err != nil {
logger.Fatalf("Invalid data format: %s", dataPath)
}