2019-02-21 04:38:45 +00:00
|
|
|
package main
|
|
|
|
|
|
2019-02-22 03:18:08 +00:00
|
|
|
import (
|
|
|
|
|
"internal-tools-server/api"
|
2019-02-26 17:06:21 +00:00
|
|
|
"internal-tools-server/storage"
|
2019-02-22 03:18:08 +00:00
|
|
|
"log"
|
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
|
|
"github.com/julienschmidt/httprouter"
|
|
|
|
|
)
|
2019-02-21 04:38:45 +00:00
|
|
|
|
|
|
|
|
func main() {
|
2019-02-26 17:06:21 +00:00
|
|
|
// Initialize the database
|
|
|
|
|
var err error
|
|
|
|
|
storage.StorageEngine, err = storage.CreateDatastore("postgres")
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Fatalln("Exception while creating datastore")
|
|
|
|
|
}
|
2019-02-22 03:18:08 +00:00
|
|
|
|
|
|
|
|
router := httprouter.New()
|
|
|
|
|
|
2019-02-26 17:06:21 +00:00
|
|
|
// Account CRUD Endpoints
|
|
|
|
|
|
|
|
|
|
// Component CRUD Endpoints
|
|
|
|
|
router.GET("/api/v1/components", api.GetComponents)
|
2019-02-26 17:52:37 +00:00
|
|
|
router.POST("/api/v1/components", api.CreateComponents)
|
2019-02-26 17:06:21 +00:00
|
|
|
|
|
|
|
|
// Page CRUD Endpoints
|
|
|
|
|
|
|
|
|
|
// Query CRUD Endpoints
|
2019-02-22 03:18:08 +00:00
|
|
|
|
|
|
|
|
log.Fatal(http.ListenAndServe(":8000", router))
|
|
|
|
|
}
|