Created Front-end files router
This commit is contained in:
@@ -12,10 +12,19 @@ func ping(w http.ResponseWriter, r *http.Request) {
|
|||||||
fmt.Fprint(w, "pong")
|
fmt.Fprint(w, "pong")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func serveStaticFile(fileName string) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
http.ServeFile(w, r, "front_files/"+fileName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func BuildRouter(listenAddress string) {
|
func BuildRouter(listenAddress string) {
|
||||||
mainRouter := mux.NewRouter()
|
mainRouter := mux.NewRouter()
|
||||||
|
|
||||||
mainRouter.HandleFunc("/ping", ping)
|
mainRouter.HandleFunc("/ping", ping)
|
||||||
|
mainRouter.HandleFunc("/", serveStaticFile("index.html"))
|
||||||
|
mainRouter.HandleFunc("/index.js", serveStaticFile("index.js"))
|
||||||
|
mainRouter.HandleFunc("/index.css", serveStaticFile("index.css"))
|
||||||
|
|
||||||
// api_router := base_router.PathPrefix("/api").Subrouter()
|
// api_router := base_router.PathPrefix("/api").Subrouter()
|
||||||
|
|
||||||
|
|||||||
0
front_files/index.css
Normal file
0
front_files/index.css
Normal file
3
front_files/index.html
Normal file
3
front_files/index.html
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
|
<title>Echo: True Peer-to-Peer file and text transfers</title>
|
||||||
0
front_files/index.js
Normal file
0
front_files/index.js
Normal file
Reference in New Issue
Block a user