mirror of
https://github.com/maputnik/editor.git
synced 2026-07-17 03:17:26 +00:00
Add option to serve directory under /static/ (from #2)
This commit is contained in:
+10
@@ -32,6 +32,10 @@ func main() {
|
|||||||
Value: 8000,
|
Value: 8000,
|
||||||
Usage: "TCP port to listen on",
|
Usage: "TCP port to listen on",
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "static",
|
||||||
|
Usage: "Serve directory under /static/",
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
app.Action = func(c *cli.Context) error {
|
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))
|
router.PathPrefix("/").Handler(http.StripPrefix("/", gui))
|
||||||
loggedRouter := handlers.LoggingHandler(os.Stdout, router)
|
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)
|
corsRouter := handlers.CORS(handlers.AllowedHeaders([]string{"Content-Type"}), handlers.AllowedMethods([]string{"GET", "PUT"}), handlers.AllowedOrigins([]string{"*"}), handlers.AllowCredentials())(loggedRouter)
|
||||||
|
|||||||
Reference in New Issue
Block a user