Created
July 3, 2014 13:06
-
-
Save pinscript/5d67ac18b6fd344cf183 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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