1
0

2 Commity c79ec6b7a8 ... 5c91ab7f50

Autor SHA1 Správa Dátum
  luis 5c91ab7f50 front end makefile fixes 6 rokov pred
  luis 805efa30c3 go fix 6 rokov pred

+ 0 - 0
.boiler/templates/gofile.go.boiler


+ 40 - 2
.boiler/templates/gomain.go.boiler

@@ -1,8 +1,46 @@
 // {{.author}} {{.email}}
+
+
 package main
 
-import "fmt"
+import (
+	"log"
+	"net/http"
+	"net/http/httputil"
+	"net/url"
+	"os"
+
+	"github.com/gohxs/prettylog"
+	"github.com/gohxs/webu"
+)
 
 func main() {
-	fmt.Println("Hello world")
+	prettylog.Global()
+
+	mux := http.NewServeMux()
+
+	var assetHandler http.Handler
+	if os.Getenv("DEBUG") == "1" {
+		//log.Println("DEBUG MODE: reverse proxy localhost:8081")
+		proxyURL, err := url.Parse("http://localhost:8080")
+		if err != nil {
+			log.Fatal(err)
+		}
+
+		rp := httputil.NewSingleHostReverseProxy(proxyURL)
+		rp.ErrorLog = prettylog.New("rproxy")
+		assetHandler = rp
+	} else {
+		// Check folder web?
+		assetHandler = webu.StaticHandler("web", "index.html")
+		//staticHandler = flowuiassets.AssetHandleFunc
+	}
+
+	// Reverse proxy
+	//
+	mux.Handle("/", assetHandler)
+
+	log.Println("Listening at port: :2000")
+
+	http.ListenAndServe(":2000", mux)
 }

+ 6 - 5
Makefile.boiler

@@ -13,15 +13,16 @@ DIST/{{.binary}}: DIST
 
 
 frontend/node_modules:
-	cd frontend; yarn
-frontend/dist: flow-ui/node_modules
+	cd frontend; yarn; yarn -D
+
+frontend/dist: frontend/node_modules
 	cd frontend; yarn build
 
 
 backend: DIST/{{.binary}}
-frontend: {{.frontend}}/dist
+frontend: frontend/dist
 
-dev: clean backend
+dev: clean backend frontend
 	tmux split "DEBUG=1 DIST/{{.binary}};$$SHELL"
 	cd frontend; yarn dev
 
@@ -33,5 +34,5 @@ generate:
 
 
 
-.PHONY: all clean frontend backend builder generate DIST/{{.binary}} 
+.PHONY: all clean backend builder generate DIST/{{.binary}} 
 

+ 1 - 1
env.sh

@@ -1,3 +1,3 @@
-export GOPATH="$(pwd)/go/deps;$(pwd)/go" 
+export GOPATH="$(pwd)/go/deps:$(pwd)/go" 
 export PS1="[GO:$(basename $(pwd))]\\n$PS1"