Created
August 1, 2019 06:52
-
-
Save kamal-kambe/e935c97ac4ab151f076776e137b7a87b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"net/http" | |
"sample-app/handler" | |
"sample-app/provider" | |
"sample-app/provider/sql" | |
"sample-app/service" | |
) | |
func main() { | |
// Initialize DB | |
db, err := provider.InitDB() | |
if err != nil { | |
panic(err) | |
} | |
defer db.Close() | |
// create storage factory | |
storageFactory := sql.NewStorage(db) | |
// create service factory | |
serviceFactory := service.New(storageFactory) | |
r := handler.InitRouter(serviceFactory) | |
if err := http.ListenAndServe(":8080", r); err != nil { | |
panic(err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment