net/http
客户端实现
Get/Head/Post和PostForm函数发出HTTP/HTTPS请求
服务端实现
func Handle(pattern string, handler Handler)
注册HTTP服务器handler和对应的模式pattern(注册到DefaultServerMux),如果该模式已经注册有一个处理器,Handle会panic.ServerMux的文档解释了模式的匹配机制。
type httpServer struct{
}
func(server httpServer)ServerHTTP(w http.ResponseWriter,r *http.Request){
w.Write([]byte(r.URL.Path))
}
func main(){
var server httpServer
http.Handle("/",server)
}
func HandleFunc(pattern string, handler func(ResponseWriter, *Request))
注册一个handler到对应的pattern(注册到DefaultS