diff --git a/maputnik.go b/maputnik.go index fc686bda..d426f827 100644 --- a/maputnik.go +++ b/maputnik.go @@ -32,6 +32,10 @@ func main() { Value: 8000, Usage: "TCP port to listen on", }, + cli.StringFlag{ + Name: "static", + Usage: "Serve directory under /static/", + } } app.Action = func(c *cli.Context) error { @@ -57,6 +61,12 @@ func main() { } } + staticDir := c.String("static") + if staticDir != "" { + h := http.StripPrefix("/static/", http.FileServer(http.Dir(staticDir))) + router.PathPrefix("/static/").Handler(h) + } + router.PathPrefix("/").Handler(http.StripPrefix("/", gui)) loggedRouter := handlers.LoggingHandler(os.Stdout, router) corsRouter := handlers.CORS(handlers.AllowedHeaders([]string{"Content-Type"}), handlers.AllowedMethods([]string{"GET", "PUT"}), handlers.AllowedOrigins([]string{"*"}), handlers.AllowCredentials())(loggedRouter)