forked from cloud-barista/cloud-barista
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
135 lines (103 loc) · 3.84 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
package main
import (
"html/template"
"io"
"net/http"
controller "github.com/cloud-barista/cb-webtool/src/controller"
echosession "github.com/go-session/echo-session"
"github.com/labstack/echo"
"github.com/labstack/echo/middleware"
)
func init() {
}
type user struct {
Name string `json:"name" form:"name" query:"name"`
Email string `json:"email" form:"email" query:"email"`
}
type connectionInfo struct {
RegionName string `json:"regionname"`
ConfigName string
ProviderName string `json:"ProviderName"`
CredentialName string `json:"CredentialName"`
DriverName string `json:"DriverName"`
}
type TemplateRender struct {
templates *template.Template
}
func (t *TemplateRender) Render(w io.Writer, name string, data interface{}, c echo.Context) error {
if viewContext, isMap := data.(map[string]interface{}); isMap {
viewContext["reverse"] = c.Echo().Reverse
}
return t.templates.ExecuteTemplate(w, name, data)
}
func requestApi(method string, restUrl string, body io.Reader) {
}
func init() {
}
func main() {
e := echo.New()
e.Use(echosession.New())
e.Use(middleware.Logger())
e.Use(middleware.Recover())
e.Use(middleware.CORSWithConfig(middleware.CORSConfig{
AllowOrigins: []string{"*"},
AllowMethods: []string{http.MethodGet, http.MethodPut, http.MethodPost, http.MethodDelete},
}))
// e.Use(middleware.CORSWithConfig(middleware.CORSConfig{
// AllowOrigins: []string{"http://210.207.104.150"},
// AllowMethods: []string{http.MethodGet, http.MethodPut, http.MethodPost, http.MethodDelete},
// }))
e.Static("/assets", "./src/static/assets")
// paresGlob 를 사용하여 모든 경로에 있는 파일을 가져올 경우 사용하면 되겠다.
// 사용한다음에 해당 파일을 불러오면 되네.
// 서브디렉토리에 있는 걸 확인하기가 힘드네....
renderer := &TemplateRender{
templates: template.Must(template.ParseGlob(`./src/views/*.html`)),
}
e.Renderer = renderer
e.GET("/", controller.IndexController)
e.GET("/dashboard", controller.DashBoard)
//login 관련
e.GET("/login", controller.LoginForm)
e.POST("/login/proc", controller.LoginController)
e.POST("/regUser", controller.RegUserConrtoller)
e.GET("/logout", controller.LogoutForm)
e.GET("/logout/proc", controller.LoginController)
// Monitoring Control
e.GET("/monitoring", controller.MornitoringListForm)
e.GET("/monitoring/install/agent/:mcis_id/:vm_id/:public_ip", controller.AgentRegForm)
// MCIS
e.GET("/MCIS/reg", controller.McisRegForm)
e.GET("/MCIS/reg/:mcis_id/:mcis_name", controller.VMAddForm)
e.POST("/MCIS/reg/proc", controller.McisRegController)
e.GET("/MCIS/list", controller.McisListForm)
// Resource
e.GET("/Resource/board", controller.ResourceBoard)
// 웹툴에서 사용할 rest
e.GET("/SET/NS/:nsid", controller.SetNameSpace)
// 웹툴에서 처리할 NameSpace
e.GET("/NS/list", controller.NsListForm)
e.GET("/NS/reg", controller.NsRegForm)
e.POST("/NS/reg/proc", controller.NsRegController)
e.GET("/GET/ns", controller.GetNameSpace)
// 웹툴에서 처리할 Connection
e.GET("/Connection/list", controller.ConnectionListForm)
e.GET("/Connection/reg", controller.ConnectionRegForm)
e.POST("/Connection/reg/proc", controller.NsRegController)
// 웹툴에서 처리할 Region
e.GET("/Region/list", controller.RegionListForm)
e.GET("/Region/reg", controller.RegionRegForm)
e.POST("/Region/reg/proc", controller.NsRegController)
// 웹툴에서 처리할 Credential
e.GET("/Credential/list", controller.CredertialListForm)
e.GET("/Credential/reg", controller.CredertialRegForm)
// 웹툴에서 처리할 Driver
e.GET("/Driver/list", controller.DriverListForm)
e.GET("/Driver/reg", controller.DriverRegForm)
// 웹툴에서 Select Pop
e.GET("/Pop/spec", controller.PopSpec)
// MAP Test
e.GET("/map", controller.Map)
e.GET("/map/geo/:mcis_id", controller.GeoInfo)
e.Logger.Fatal(e.Start(":1234"))
}