Created
January 9, 2018 10:16
-
-
Save e7/2f641be2e8a5c6283520a20354bf3928 to your computer and use it in GitHub Desktop.
简单的http文件服务器
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"net/http" | |
"github.com/urfave/negroni" | |
) | |
func main() { | |
mux := http.NewServeMux() | |
mux.Handle("/", http.FileServer(http.Dir("."))) | |
// Example of using a http.FileServer if you want "server-like" rather than "middleware" behavior | |
// mux.Handle("/public", http.FileServer(http.Dir("/home/public"))) | |
n := negroni.New() | |
n.UseHandler(mux) | |
http.ListenAndServe(":8000", n) | |
return | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment