21 lines
379 B
Go
21 lines
379 B
Go
package route
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/gin-contrib/static"
|
|
"github.com/gin-gonic/gin"
|
|
"os"
|
|
"path/filepath"
|
|
)
|
|
|
|
func Static(e *gin.Engine) {
|
|
execPath, err := os.Executable()
|
|
if err != nil {
|
|
panic("invalid executable path")
|
|
}
|
|
|
|
execDir := filepath.Dir(execPath)
|
|
webPath := fmt.Sprintf("%s/static", execDir)
|
|
e.Use(static.Serve("/", static.LocalFile(webPath, true)))
|
|
}
|