forked from USACE/mcat-ras
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
49 lines (39 loc) · 1.48 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package main
import (
"github.com/Dewberry/mcat-ras/config"
"github.com/Dewberry/mcat-ras/handlers"
"github.com/Dewberry/mcat-ras/pgdb"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
// echoSwagger "github.com/swaggo/echo-swagger"
)
func main() {
// Connect to backend services
appConfig := config.Init()
dbConfig := pgdb.DBInit()
// Instantiate echo
e := echo.New()
e.Use(middleware.Logger())
e.Use(middleware.Recover())
e.Use(middleware.Gzip())
// HealthCheck
e.GET("/ping", handlers.Ping(appConfig.FileStore))
// Swagger
// e.GET("/swagger/*", echoSwagger.WrapHandler)
// ras endpoints
// these endpoints create a Ras Model struct from files
// and then apply receiver functions to the struct to answer desired question
e.GET("/isamodel", handlers.IsAModel(appConfig.FileStore))
e.GET("/modeltype", handlers.ModelType(appConfig.FileStore))
e.GET("/modelversion", handlers.ModelVersion(appConfig.FileStore))
e.GET("/index", handlers.Index(appConfig.FileStore))
e.GET("/isgeospatial", handlers.IsGeospatial(appConfig.FileStore))
e.GET("/geospatialdata", handlers.GeospatialData(appConfig))
e.GET("/forcingdata", handlers.ForcingData(appConfig))
// pgdb endpoints
e.POST("/upsert/model", pgdb.UpsertRasModel(appConfig, dbConfig))
e.POST("/upsert/geometry", pgdb.UpsertRasGeometry(appConfig, dbConfig))
e.POST("/refresh", pgdb.RefreshRasViews(dbConfig))
e.POST("/vacuum", pgdb.VacuumRasViews(dbConfig))
e.Logger.Fatal(e.Start(appConfig.Address()))
}