-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
34 lines (31 loc) · 918 Bytes
/
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
package main
import (
. "myfabric-tool/bindata"
. "myfabric-tool/controller"
"html/template"
"log"
"net/http"
)
func main() {
//to run 'go-bindata-assetfs -o "bindata/bindata.go" -pkg bindata static/...' in terminal
ConfigRouter()
err := http.ListenAndServe(":8080", nil)
if err != nil {
log.Fatal("start server failed, reson is : ", err)
}
}
func ConfigRouter(){
http.Handle("/", http.FileServer(AssetFS()))
http.HandleFunc("/index", Index)
http.HandleFunc("/channel/list",ChannelList)
http.HandleFunc("/channel/listJson",ChannelListJson)
http.HandleFunc("/channel/getInfo",ChannelGetInfo)
http.HandleFunc("/channel/getInfoJson",ChannelGetInfoJson)
http.HandleFunc("/channel/fetch", ChannelFetch)
http.HandleFunc("/channel/fetchJson", ChannelFetchJson)
}
func Index(w http.ResponseWriter, r *http.Request){
t, _ := template.ParseFiles("static/index.html")
//执行模板
t.Execute(w,nil)
}