2 Achegas c79ec6b7a8 ... 5c91ab7f50

Autor SHA1 Mensaxe Data
  luis 5c91ab7f50 front end makefile fixes %!s(int64=6) %!d(string=hai) anos
  luis 805efa30c3 go fix %!s(int64=6) %!d(string=hai) anos
Modificáronse 4 ficheiros con 47 adicións e 8 borrados
  1. 0 0
      .boiler/templates/gofile.go.boiler
  2. 40 2
      .boiler/templates/gomain.go.boiler
  3. 6 5
      Makefile.boiler
  4. 1 1
      env.sh

+ 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"