首页 > 代码库 > Go http.HandlerFunc()

Go http.HandlerFunc()

//http.Handlertype Handler interface {    ServeHTTP(ResponseWriter, *Request)}
type HandlerFunc func(ResponseWriter, *Request)func (HandlerFunc) ServeHTTP


一般当创建一个如下的方法时,可通过http.HandlerFunc(name)转换为Handler类型,因为HanderFunc里有ServeHttp方法,实现了Handler接口

func name(rw ResponseWrite, r *Request){}