These are chat archives for gin-gonic/gin

13th
Jun 2015
Testarossa
@testarossaaaaa
Jun 13 2015 06:42 UTC
curl output is clear now
uncomment the lines below and you get <pre> tag in curl output
package main

import (
    // "github.com/gin-gonic/contrib/static"
    "github.com/gin-gonic/gin"
    "html/template"
)

func main() {
    r := gin.Default()
    html := template.Must(template.New("index.html").Parse("<!DOCTYPE html><html><head></head><body></body></html>"))

    r.SetHTMLTemplate(html)
    // r.Use(static.Serve("/", static.LocalFile("/tmp", false)))

    r.GET("/", func(c *gin.Context) {
        c.HTML(200, "index.html", gin.H{
            "test": "test",
        })
    })

    r.Run(":8080")
}
Manu MA
@manucorporat
Jun 13 2015 09:10 UTC
I may found a way to fix it
@DenisNeustroev
func existsFile(name string) bool {
    stats, err := os.Stat(name)
    return !os.IsNotExist(err) && !stats.IsDir()
}
adding "&& !stats.IsDir()"
Testarossa
@testarossaaaaa
Jun 13 2015 10:20 UTC
@manucorporat thank you again
Manu MA
@manucorporat
Jun 13 2015 10:21 UTC
try to update the middleware
go get -u github.com/gin-gonic/contrib/static
let me know if it works
Halil ibrahim Onay
@hionay
Jun 13 2015 22:48 UTC
hey
anybody there?
[GIN-debug] GET /:short --> main.Redirect (3 handlers)
[GIN-debug] GET /shorten/:url --> main.Shorten (3 handlers)
panic: path segment 'shorten/:url' conflicts with existing wildcard ':short' in path '/shorten/:url'
I get this error
and my code is:
r.GET("/:short", Redirect)
r.GET("/shorten/:url", Shorten)