46 lines
1.1 KiB
Go
46 lines
1.1 KiB
Go
// package main
|
|
|
|
// import "fmt"
|
|
|
|
// func main() {
|
|
// fmt.Println("Hello!")
|
|
// }
|
|
|
|
package main
|
|
|
|
import (
|
|
"log"
|
|
"net/http"
|
|
|
|
"github.com/gorilla/handlers"
|
|
|
|
dashapi "github.com/moustachioed/dash/backend/dashapi"
|
|
database "github.com/moustachioed/dash/backend/database"
|
|
mapping "github.com/moustachioed/dash/backend/mapping"
|
|
service "github.com/moustachioed/dash/backend/service"
|
|
)
|
|
|
|
func main() {
|
|
db, err := database.NewPgDatabase("localhost", "dash", "dash", "dash", 15432)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
mapper := mapping.NewMapperImpl()
|
|
|
|
DefaultApiService := service.NewApiService(db, mapper)
|
|
DefaultApiController := dashapi.NewDefaultApiController(DefaultApiService)
|
|
|
|
cors := handlers.CORS(
|
|
// handlers.AllowedMethods([]string{"GET", "POST", "DELETE"}),
|
|
handlers.AllowedHeaders([]string{"Accept", "Accept-Language", "Content-Type", "Content-Language", "Origin"}),
|
|
handlers.AllowedOrigins([]string{"*"}),
|
|
)
|
|
|
|
router := dashapi.NewRouter(DefaultApiController)
|
|
router.Methods("GET", "POST", "DELETE", "OPTIONS")
|
|
|
|
log.Printf("Starting server.")
|
|
log.Fatal(http.ListenAndServe(":8080", cors(router)))
|
|
}
|