Files
fasthttp/examples/fileserver/fileserver.go
T
2015-12-04 15:09:12 +02:00

24 lines
492 B
Go

// Example static file server. Serves static files from the given directory.
package main
import (
"flag"
"log"
"github.com/valyala/fasthttp"
)
var (
addr = flag.String("addr", ":8080", "TCP address to listen to")
dir = flag.String("dir", "/usr/share/nginx/html", "Directory to serve static files from")
)
func main() {
flag.Parse()
h := fasthttp.FSHandler(*dir, 0)
if err := fasthttp.ListenAndServe(*addr, h); err != nil {
log.Fatalf("error in ListenAndServe: %s", err)
}
}