contrib
contrib copied to clipboard
static middleware doesn't work on Windows
static middleware uses os.Stat which is not for Windows.
stats, err := os.Stat(name)
Also
package main
import (
"os"
"github.com/gin-gonic/contrib/static"
"github.com/gin-gonic/gin"
)
func main() {
r := gin.Default()
r.Use(static.Serve("/", static.LocalFile(os.Getenv("HOME"), true)))
r.GET("/ping", func(c *gin.Context) {
c.String(200, "test")
})
r.Run(":8080")
}
Return 404 page not found. But it works in Linux.
I have no Windows machine to try this out; however, by looking at the Go source code, os.Stat() was patched a few times during 2016/2017 in order to provide better support under Windows and make it 'more compatible' with the routines calling os.Stat(). As such, this ought to be working fine (in 2023!). Can someone confirm that?