Skip to content

Instantly share code, notes, and snippets.

@pinscript
Created July 3, 2014 13:06
Show Gist options
  • Save pinscript/5d67ac18b6fd344cf183 to your computer and use it in GitHub Desktop.
Save pinscript/5d67ac18b6fd344cf183 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"time"
"github.com/alexandernyquist/gin" // at 30ea9c06fc9cac893f10d6ad0847a510cf35aeaf
)
func main() {
r := gin.NewWithConfig(gin.Config{
CacheSize: 5,
Preallocated: 3,
})
r.GET("", func (g *gin.Context) {
g.JSON(200, gin.H{"foo":"bar"})
time.Sleep(100 * time.Millisecond)
})
r.GET("/long", func (g *gin.Context) {
go func() {
time.Sleep(20 * time.Second)
fmt.Printf("Url (only available via /long): %s\n", g.Req.URL.String())
}()
g.JSON(200, gin.H{"foo":"bar"})
})
r.Run(":8082")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment