我想让当有人访问我的 Go HTTP 服务器上的页面时,他们不会看到.html扩展。例如,当他们访问时,https://example.org/test他们会看到https://example.org/test.html.
我的代码:
package main
import (
"net/http"
)
func main() {
fs := http.FileServer(http.Dir("public/"))
http.Handle("/", http.StripPrefix("/", fs))
http.ListenAndServe(":8000", nil)
}
Run Code Online (Sandbox Code Playgroud)