
net/http 源码分析
1. Step One
- Read the article https://www.cnblogs.com/zhaof/p/8569743.html
- Open the http src code,dive into code with the chart
- There are two main step :
- http.HandleFunc(“/“,IndexHandler)
create a map[string]muxEntry to record the [ url->handlefunc ]
- http.ListenAndServer(“127.0.0.1:8000”,nil)
start a tcp listen : ln, err := net.Listen(“tcp”, addr)
accept request and handle it :srv.Serve(tcpKeepAliveListener{ln.(*net.TCPListener)})
- http.HandleFunc(“/“,IndexHandler)




近期评论