These are chat archives for gin-gonic/gin

21st
May 2015
Joonathan Mägi
@joonathan
May 21 2015 11:20
is there a way to serve /favicon.ico from the assets folder using r.Static in some way? but have generic / route defined as well serving something else?
I do have r.Static("/assets", "./assets") in place and also a route for /, but would love to be able to get rid of 404's for /favicon.ico too
Manu MA
@manucorporat
May 21 2015 12:31
@joonathan c.File("favicon.ico", "./myfavicon.ico")
sorry! I was mistaken
you have to route it:
c.GET("/favicon.ico", func(c *gin.Context) {
c.File("./myfavicon.ico")
})
but since this is very interesting use case, I am going to experiment with a new API:
router.StaticFile("/favicon.ico", "./myfavicon.ico")
how does it sound?
Javier Provecho Fernandez
@javierprovecho
May 21 2015 12:39
@manucorporat looks nice, those are good shortcuts. I'll document them to avoid mess routing for each file. Only for exceptions like favicon
Joonathan Mägi
@joonathan
May 21 2015 12:47
Sounds great
thanks, I'll go for the c.File way for now and update when the StaticFile is available
Manu MA
@manucorporat
May 21 2015 12:49
" Only for exceptions like favicon" I do not agree
another examples:
c.StaticFile("/", "index.html")
Ryan Brooks
@ryanbyyc
May 21 2015 14:49
c.StaticFile("/", "index.html”) - That’d be a great way to implement a maintenance mode system
Manu MA
@manucorporat
May 21 2015 15:02
it's done! gin-gonic/gin@72f200a
I also added a way to disable the listing of files in a directoy
it is the new default setting : no listing
Ryan Brooks
@ryanbyyc
May 21 2015 15:04
strings.Contains(relativePath, "*”) Yup. That’s great. c.StaticFile("*", "http://vignette2.wikia.nocookie.net/uncyclopedia/images/7/7b/Dancing_banana.gif/revision/latest?cb=20071019155930”)
Manu MA
@manucorporat
May 21 2015 15:05
you can not use a HTTP URL
only local URLs
Ryan Brooks
@ryanbyyc
May 21 2015 15:05
bah.
Well, sentiment is correct at least. ;)
Manu MA
@manucorporat
May 21 2015 15:06
hahahahah I just show the image :D
btw, this is the code I am using the disable directory listing: