Angular
3
Вклад в тег
type logWrapper struct {
http.Handler
}
func (wr logWrapper) ServeHTTP(w http.ResponseWriter, r *http.Request) {
log.Printf("%s %s %s\n", r.Method, r.URL, time.Now())
wr.Handler.ServeHTTP(w, r)
}
func main() {
router := mux.NewRouter()
s := http.StripPrefix("/static/", http.FileServer(http.Dir("./files/")))
router.HandleFunc("/", Index)
router.HandleFunc("/login", LogIn)
router.HandleFunc("/logout", LogOut)
FileHandler := http.HandlerFunc(File)
router.Handle("/file.html", logWrapper{FileHandler})
router.PathPrefix("/static/").Handler(s)
http.Handle("/", router)
http.ListenAndServe(":5000", nil)
}
func Index(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "hello")
}
func File(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "это обрабатывается в обёртке)) ")
}