官术网_书友最值得收藏!

FileServer

A FileServer function returns a handler that serves HTTP requests with the contents of the filesystem. This can be used to serve static files such as images or other content that is stored on the file system:

func FileServer(root FileSystem) Handler 

Take a look at the following code:

http.Handle("/images", http.FileServer(http.Dir("./images")))

This allows us to map the contents of the file system path ./images to the server route /images, Dir implements a file system which is restricted to a specific directory tree, the FileServer method uses this to be able to serve the assets.

主站蜘蛛池模板: 波密县| 嵊泗县| 荣成市| 灯塔市| 金乡县| 东乡族自治县| 综艺| 时尚| 寿阳县| 扬中市| 凤台县| 广德县| 牙克石市| 兴城市| 虎林市| 宜章县| 大石桥市| 嘉义市| 宁蒗| 安塞县| 江达县| 九江县| 扎赉特旗| 纳雍县| 金华市| 玛沁县| 石台县| 德令哈市| 旌德县| 兴义市| 景谷| 裕民县| 汶川县| 麟游县| 定陶县| 夏河县| 门头沟区| 京山县| 英超| 五大连池市| 元谋县|