VILLASweb-backend-go/start.go
smavros 8216767722 Changes in the user package:
- Moves `POST /users` to the users endpoint group where
    authentication is required
    - Renames userLogin to loginRequest
    - Adds userMethods.go source file to the package user
    - Adds type User in the user package which just wrapps the type
    common.User so methods can be added to the type
    - Adds prototypes of methods for setting/validating password and
    updating type User's data
2019-05-20 12:04:37 +02:00

44 lines
1.5 KiB
Go

package main
import (
"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/project"
"git.rwth-aachen.de/acs/public/villas/villasweb-backend-go/routes/simulation"
"git.rwth-aachen.de/acs/public/villas/villasweb-backend-go/routes/simulationmodel"
"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"
"github.com/gin-gonic/gin"
)
func main() {
// Testing
db := common.DummyInitDB()
common.MigrateModels(db)
defer db.Close()
common.DummyPopulateDB(db)
r := gin.Default()
api := r.Group("/api/v1")
// All endpoints require authentication except when someone wants to
// login (POST /authenticate)
user.VisitorAuthenticate(api.Group("/authenticate"))
api.Use(user.Authentication(true))
user.UsersRegister(api.Group("/users"))
file.FilesRegister(api.Group("/files"))
project.ProjectsRegister(api.Group("/projects"))
simulation.SimulationsRegister(api.Group("/simulations"))
simulationmodel.SimulationModelsRegister(api.Group("/models"))
simulator.SimulatorsRegister(api.Group("/simulators"))
visualization.VisualizationsRegister(api.Group("/visualizations"))
// server at port 4000 to match frontend's redirect path
r.Run(":4000")
}