forked from fernandezpablo85/react-typescript-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
25 lines (20 loc) · 650 Bytes
/
main.go
File metadata and controls
25 lines (20 loc) · 650 Bytes
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
package main
import (
"github.com/gorilla/mux"
"net/http"
)
func HomePage(w http.ResponseWriter, r *http.Request) {
if err := templates.ExecuteTemplate(w, "index", nil); err != nil {
logger.WithField("template", "index").Errorf("template not found")
w.WriteHeader(http.StatusInternalServerError)
}
}
func main() {
router := mux.NewRouter()
handler := http.StripPrefix("/public", http.FileServer(http.Dir("./public")))
router.PathPrefix("/public").Handler(handler)
router.HandleFunc("/", HomePage).Methods("GET")
address := ":8080"
logger.Infof("server started on %s", address)
logger.Fatal(http.ListenAndServe(address, router))
}