I develop web application, But I can't load image. .css and .js file can be loaded by Static() method. Image is also same? How to load Image to web application using Gin?
router.Static("/css", "./css") // this is loading css file
router.Static("/js", "./js") // this is loading js file
// How to load Image?
You may use StaticFile to serve a single file
router.StaticFile("/favicon.ico", "./resources/favicon.ico")
If you want to serve static image given its path,you may use it just like js and css
router.Static("/img", "./img")
or
import "github.com/gin-gonic/contrib/static"
.
.
.
router.Use(static.Serve("/img", static.LocalFile("./img", true)))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With