servedir/main.go

19 lines
330 B
Go

package main
import (
"log"
"net/http"
)
func logger(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
log.Printf("%s: %s\n", r.RemoteAddr, r.URL)
h.ServeHTTP(w, r)
})
}
func main() {
fh := http.FileServer(http.Dir("./"))
http.ListenAndServe(":8080", logger(fh))
}