go net/http 源码阅读
实现一个简单的http服务器:
package net_http
import (
"net/http"
"testing"
)
func index(response http.ResponseWriter, request *http.Request) {
response.WriteHeader(http.StatusOK)
response.Write([]byte("index"))
}
func TestHttpServer(t *testing.T) {
tmux := http.NewServeMux()
tmux.HandleFunc("/", index)
tmux.HandleFunc("/index", index)
http.ListenAndServe("0.0.0.0:9055",tmux)
}