mirror of
https://github.com/maputnik/editor.git
synced 2026-08-02 11:17:26 +00:00
Merge pull request #5 from JesseCrocker/choose-listen-port
Add option to choose a listening port
This commit is contained in:
@@ -37,6 +37,12 @@ use Maputnik.
|
|||||||
maputnik --watch --file basic-v9.json
|
maputnik --watch --file basic-v9.json
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Choose a local port to listen on, instead of using the default port 8000.
|
||||||
|
|
||||||
|
```
|
||||||
|
maputnik --port 8001
|
||||||
|
```
|
||||||
|
|
||||||
### API
|
### API
|
||||||
|
|
||||||
`maputnik` exposes the configured styles via a HTTP API.
|
`maputnik` exposes the configured styles via a HTTP API.
|
||||||
|
|||||||
+7
-2
@@ -27,6 +27,11 @@ func main() {
|
|||||||
Name: "watch",
|
Name: "watch",
|
||||||
Usage: "Notify web client about JSON style file changes",
|
Usage: "Notify web client about JSON style file changes",
|
||||||
},
|
},
|
||||||
|
cli.IntFlag{
|
||||||
|
Name: "port",
|
||||||
|
Value: 8000,
|
||||||
|
Usage: "TCP port to listen on",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
app.Action = func(c *cli.Context) error {
|
app.Action = func(c *cli.Context) error {
|
||||||
@@ -56,8 +61,8 @@ func main() {
|
|||||||
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)
|
||||||
|
|
||||||
fmt.Println("Exposing Maputnik on http://localhost:8000")
|
fmt.Printf("Exposing Maputnik on http://localhost:%d\n", c.Int("port"))
|
||||||
return http.ListenAndServe(":8000", corsRouter)
|
return http.ListenAndServe(fmt.Sprintf(":%d", c.Int("port")), corsRouter)
|
||||||
}
|
}
|
||||||
|
|
||||||
app.Run(os.Args)
|
app.Run(os.Args)
|
||||||
|
|||||||
Reference in New Issue
Block a user