/
routes.go
30 lines (26 loc) · 988 Bytes
/
routes.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
package routing
import (
"github.com/labstack/echo"
"github.com/labstack/echo/middleware"
"github.com/magrandera/SPaaS/config"
"github.com/magrandera/SPaaS/server/auth"
"github.com/magrandera/SPaaS/server/controller"
)
// SetupRoutes sets up the routes for the app
func SetupRoutes(e *echo.Echo) {
e.POST("/login", auth.Login)
e.File("/", "static/index.html")
g := e.Group("")
g.Use(middleware.JWT([]byte(config.Cfg.Config.GetString("secret"))))
g.POST("/change-password", auth.ChangePassword)
r := e.Group("/api/app")
r.Use(middleware.JWT([]byte(config.Cfg.Config.GetString("secret"))))
r.GET("", controller.GetApplications)
r.GET("/:name", controller.GetApplication)
r.POST("/:name", controller.CreateApplication)
r.DELETE("/:name", controller.DeleteApplication)
r.POST("/:name/start", controller.StartApplication)
r.POST("/:name/stop", controller.StopApplication)
r.POST("/:name/deploy", controller.DeployApplication)
r.GET("/:name/logs", controller.GetLogs)
}