12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- // {{.author}} {{.email}}
- package main
- import (
- "log"
- "net/http"
- "net/http/httputil"
- "net/url"
- "os"
- "github.com/gohxs/prettylog"
- "github.com/gohxs/webu"
- )
- func main() {
- 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)
- }
|