生命不止,继续 go go go !!!
之前写过博客介绍net/http包:
《Go语言学习之net/http包(The way to go)》
package net/http
再次温习几个方法:
http.FileServer
FileServer returns a handler that serves HTTP requests with the contents of the file system rooted at root.
func StripPrefix(prefix string, h Handler)
Handler将请求url.path中移出指定的前缀,然后将省下的请求交给handler h来处理,对于那些不是以指定前缀开始的路径请求,该函数返回一个http 404 not found 的错误.
type Dir
A Dir implements FileSystem using the native file system restricted to a specific directory tree.
type Handler
A Handler responds to an HTTP request.