你在使用Go语言开发Web服务时使用的是哪个Web服务器?

huangapple go评论78阅读模式
英文:

What web server do you use with Go for web service?

问题

如果我想使用Go创建一个Web服务,我会使用哪个Web服务器?

我的Web服务需要与Mysql、redis和memcached进行交互。是否有稳定的库可用于每个服务?

英文:

If I wanted to create a web service using Go, what web server would I be using?

My web service needs to interact with Mysql, redis and memcached. Are there stable libraries for each?

答案1

得分: 18

The net/http package in the standard library is stable and concurrent (goroutine per client).

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

After reading Writing Web Applications you will have the necessary skills to write idiomatic web applications in Go.

英文:

The net/http package in the standard library is stable and concurrent (goroutine per client).

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

After reading Writing Web Applications you will have the necessary skills to write idiomatic web applications in Go.

huangapple
  • 本文由 发表于 2012年7月26日 02:31:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/11656297.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定