mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-14 11:03:53 +00:00
23 lines
408 B
Go
23 lines
408 B
Go
//go:build web
|
|
|
|
package server
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func (s *Server) assetsHandler(c *gin.Context) {
|
|
// redirect to .html page if the page exists
|
|
if pageRoutePattern.MatchString(c.Request.URL.Path) {
|
|
_, err := FS.Open(c.Request.URL.Path + ".html")
|
|
if err == nil {
|
|
c.Request.URL.Path += ".html"
|
|
}
|
|
}
|
|
|
|
fs := http.FileServer(FS)
|
|
fs.ServeHTTP(c.Writer, c.Request)
|
|
}
|