func main() { // parse command line options flag.Parse() // setup pipeline pipeline := falcore.NewPipeline() // upstream filters // Serve files pipeline.Upstream.PushBack(&filter.FileFilter{ BasePath: *path, DirectoryIndex: "index.html", // Serve index.html for root requests }) // downstream pipeline.Downstream.PushBack(filter.NewCompressionFilter(nil)) // setup server server := falcore.NewServer(*port, pipeline) // start the server // this is normally blocking forever unless you send lifecycle commands if err := server.ListenAndServe(); err != nil { fmt.Println("Could not start server:", err) } }
func main() { // parse command line options flag.Parse() // setup pipeline pipeline := falcore.NewPipeline() // upstream filters // Serve index.html for root requests pipeline.Upstream.PushBack(falcore.NewRequestFilter(func(req *falcore.Request) *http.Response { if req.HttpRequest.URL.Path == "/" { req.HttpRequest.URL.Path = "/index.html" } return nil })) // Serve files pipeline.Upstream.PushBack(&filter.FileFilter{ BasePath: *path, }) // downstream pipeline.Downstream.PushBack(filter.NewCompressionFilter(nil)) // setup server server := falcore.NewServer(*port, pipeline) // start the server // this is normally blocking forever unless you send lifecycle commands if err := server.ListenAndServe(); err != nil { fmt.Println("Could not start server:", err) } }