24 lines
492 B
Go
24 lines
492 B
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
"net/http"
|
|
)
|
|
|
|
func loggingMiddleware(next http.Handler) http.Handler {
|
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
log.Printf("%s %s %s", r.RemoteAddr, r.Method, r.URL.Path)
|
|
next.ServeHTTP(w, r)
|
|
})
|
|
}
|
|
|
|
func main() {
|
|
fs := http.FileServer(http.Dir("."))
|
|
http.Handle("/", loggingMiddleware(fs))
|
|
log.Println("Serving on http://localhost:8888 ...")
|
|
err := http.ListenAndServe(":8888", nil)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|