2012-07-25 110 views

回答

18

标准库中的net/http包是稳定并发的(每个客户端的goroutine)。

http.Handle("/foo", fooHandler) 

http.HandleFunc("/bar", func(w http.ResponseWriter, r *http.Request) { 
    fmt.Fprintf(w, "Hello, %q", html.EscapeString(r.URL.Path)) 
}) 

log.Fatal(http.ListenAndServe(":8080", nil)) 

阅读Writing Web Applications后,您将具备必要的技能来写去惯用的Web应用程序。

+1

我明白了,这有点像内置码头实例吗? – loyalflow 2012-07-25 18:43:51

+1

@ user1361315除了它更轻。 – 2012-07-25 18:50:21