mirror of
https://github.com/maputnik/editor.git
synced 2026-02-14 00:20:00 +00:00
Add server and bindata packaging
This commit is contained in:
24
README.md
24
README.md
@@ -1,2 +1,26 @@
|
||||
# desktop
|
||||
A Golang based cross platform executable for integrating Maputnik locally
|
||||
|
||||
|
||||
### Build
|
||||
|
||||
First you need a app bundle distribution of Maptunik and copy over `public`
|
||||
to the `gui` folder in this project.
|
||||
|
||||
```
|
||||
npm run dist
|
||||
```
|
||||
|
||||
Package the the `gui` as binary assets.
|
||||
|
||||
```
|
||||
go get github.com/elazarl/go-bindata-assetfs/...
|
||||
go-bindata-assetfs gui/...
|
||||
```
|
||||
|
||||
Install the go package.
|
||||
|
||||
```
|
||||
go install
|
||||
```
|
||||
|
||||
|
||||
15
api.go
Normal file
15
api.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// Return all current deployments
|
||||
func foo(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
encoder := json.NewEncoder(w)
|
||||
encoder.Encode(map[string]string{
|
||||
"foo": "bar",
|
||||
})
|
||||
}
|
||||
29
maputnik.go
Normal file
29
maputnik.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/gorilla/handlers"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
func main() {
|
||||
app := cli.NewApp()
|
||||
app.Name = "maputnik"
|
||||
app.Usage = "Server for integrating Maputnik locally"
|
||||
|
||||
app.Action = func(c *cli.Context) error {
|
||||
gui := http.FileServer(assetFS())
|
||||
|
||||
router := mux.NewRouter().StrictSlash(true)
|
||||
//router.Path("/api/v1/apps").Methods("GET").HandlerFunc(foo)
|
||||
router.PathPrefix("/").Handler(http.StripPrefix("/", gui))
|
||||
|
||||
loggedRouter := handlers.LoggingHandler(os.Stdout, router)
|
||||
return http.ListenAndServe(":8000", loggedRouter)
|
||||
}
|
||||
|
||||
app.Run(os.Args)
|
||||
}
|
||||
Reference in New Issue
Block a user