e7
1/9/2018 - 10:16 AM

简单的http文件服务器

简单的http文件服务器

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
}