Files
video-player-demo/serve.go
2025-06-06 16:59:09 +08:00

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)
}
}