golang http.handler接口详解
golang http.handler接口详解 1.标准库接口定义 package http type Handler interface { ServeHTTP(w ResponseWriter, r *Request) } func ListenAndServe(address string, h Handler) error ListenAndServe函数需要一个例如“localhost:8000”的服务器地址,和一个处理所有请求的Handler接口实例。它会一直运行,直到这个服务因为一个错误而失败(或者启动失败),它的返回值一定是一个非空的错误。 2.小Demo type dollars float32 func (d dollars) String() string { retu...阅读全文