mirror of
https://github.com/valyala/fasthttp.git
synced 2026-06-15 16:07:51 +03:00
24 lines
492 B
Go
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)
|
|
}
|
|
}
|