mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 23:05:15 +00:00
24 lines
469 B
Go
24 lines
469 B
Go
package server
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/markbates/pkger"
|
|
)
|
|
|
|
func (s *Server) pkgerHandler(c *gin.Context) {
|
|
fs := pkger.Dir("/frontend/out")
|
|
|
|
// redirect to .html page if the page exists
|
|
if pageRoutePattern.MatchString(c.Request.URL.Path) {
|
|
|
|
_, err := pkger.Stat("/frontend/out/" + c.Request.URL.Path + ".html")
|
|
if err == nil {
|
|
c.Request.URL.Path += ".html"
|
|
}
|
|
}
|
|
|
|
http.FileServer(fs).ServeHTTP(c.Writer, c.Request)
|
|
}
|