From 8031c6066e11b75d146cfb8f872df7bdd614768f Mon Sep 17 00:00:00 2001 From: c9s Date: Fri, 29 Jan 2021 11:19:37 +0800 Subject: [PATCH] mount static files to routes --- pkg/bbgo/server.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/bbgo/server.go b/pkg/bbgo/server.go index 8671b4fca..7978a4e3c 100644 --- a/pkg/bbgo/server.go +++ b/pkg/bbgo/server.go @@ -8,6 +8,7 @@ import ( "github.com/gin-contrib/cors" "github.com/gin-gonic/gin" + "github.com/markbates/pkger" log "github.com/sirupsen/logrus" "github.com/c9s/bbgo/pkg/service" @@ -205,5 +206,10 @@ func RunServer(ctx context.Context, userConfig *Config, environ *Environment) er c.JSON(200, gin.H{"message": "pong"}) }) + fs := pkger.Dir("/frontend/out") + r.NoRoute(func(c *gin.Context) { + http.FileServer(fs).ServeHTTP(c.Writer, c.Request) + }) + return r.Run() // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080") }