-
Notifications
You must be signed in to change notification settings - Fork 4
/
app.go
49 lines (37 loc) · 1.01 KB
/
app.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 (
"fmt"
"net/http"
"vwa/util"
"vwa/util/render"
"vwa/helper/middleware"
"vwa/modules/user"
"vwa/modules/user/profile"
"vwa/modules/product/komentar"
"github.com/julienschmidt/httprouter"
)
func indexHandler(w http.ResponseWriter, r *http.Request, _ httprouter.Params){
data := make(map[string]interface{})
data["title"] = "Home"
render.HTMLRender(w,r, "template.index", data)
}
func main(){
mw := middleware.New()
router := httprouter.New()
router.ServeFiles("/assets/*filepath", http.Dir("assets/"))
router.GET("/", mw.LoggingMiddleware(indexHandler))
router.GET("/index", mw.LoggingMiddleware(indexHandler))
user := user.New()
user.SetRouter(router)
komentar := komentar.New()
komentar.SetRouter(router)
profile := profile.New()
profile.SetRouter(router)
s := http.Server{
Addr : ":"+util.Cfg.Webport,
Handler : router,
}
fmt.Printf("Server running at port %s\n", s.Addr)
fmt.Printf("Open this url %s on your browser to access VWA",util.Fullurl)
s.ListenAndServe()
}