VILLASweb-backend-go/start.go
2019-05-23 17:01:38 +02:00

61 lines
2.2 KiB
Go

package main
import (
"github.com/gin-gonic/gin"
"github.com/swaggo/gin-swagger"
"github.com/swaggo/gin-swagger/swaggerFiles"
_ "git.rwth-aachen.de/acs/public/villas/villasweb-backend-go/doc/autoapi" // apidocs folder is generated by Swag CLI, you have to import it
"git.rwth-aachen.de/acs/public/villas/villasweb-backend-go/common"
"git.rwth-aachen.de/acs/public/villas/villasweb-backend-go/routes/file"
"git.rwth-aachen.de/acs/public/villas/villasweb-backend-go/routes/model"
"git.rwth-aachen.de/acs/public/villas/villasweb-backend-go/routes/simulation"
"git.rwth-aachen.de/acs/public/villas/villasweb-backend-go/routes/simulator"
"git.rwth-aachen.de/acs/public/villas/villasweb-backend-go/routes/user"
"git.rwth-aachen.de/acs/public/villas/villasweb-backend-go/routes/visualization"
"git.rwth-aachen.de/acs/public/villas/villasweb-backend-go/routes/widget"
)
// @title VILLASweb Backend API
// @version 2.0
// @description This is the API of the VILLASweb Backend
// @description WORK IN PROGRESS! PLEASE BE PATIENT!
// @description This documentation is auto-generated based on the API documentation in the code.
// @description The tool https://github.com/swaggo/swag is used to auto-generate API docs for gin.
// @contact.name Sonja Happ
// @contact.email sonja.happ@eonerc.rwth-aachen.de
// @license.name GNU GPL 3.0
// @license.url http://www.gnu.de/documents/gpl-3.0.en.html
// @host aaa.bbb.ccc.ddd:pppp
// @BasePath /api/v2
func main() {
// Testing
db := common.InitDB()
common.MigrateModels(db)
defer db.Close()
r := gin.Default()
api := r.Group("/api")
// use ginSwagger middleware to
simulation.RegisterSimulationEndpoints(api.Group("/simulations"))
file.RegisterFileEndpoints(api.Group("/simulations"))
model.RegisterModelEndpoints(api.Group("/simulations"))
visualization.RegisterVisualizationEndpoints(api.Group("/simulations"))
widget.RegisterWidgetEndpoints(api.Group("/simulations"))
user.RegisterUserEndpointsForSimulation(api.Group("/simulations"))
user.RegisterUserEndpoints(api.Group("/users"))
simulator.RegisterSimulatorEndpoints(api.Group("/simulators"))
r.GET("swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
r.Run()
}