package main
import (
"io"
"log"
"net/http"
)
func main() {
mux := http.NewServeMux()
mux.Handle("/", &myHandler{})
err := http.ListenAndServe(":8080", mux)
if err != nil {
log.Fatal(err)
}
}
type myHandler struct {}
func (*myHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
io.WriteString(w, "hello")
}
go web编程-使用Mux控制路由访问
最新推荐文章于 2024-06-17 22:25:35 发布