feat: init

This commit is contained in:
yanghao05
2025-06-06 16:59:09 +08:00
parent d3dd322649
commit b0d5bceb09
40 changed files with 11149 additions and 0 deletions

23
serve.go Normal file
View File

@@ -0,0 +1,23 @@
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)
}
}