From 66fa43f9aea4ecf627f269b43ddad59f206f9b75 Mon Sep 17 00:00:00 2001 From: Manu Mtz-Almeida Date: Fri, 22 May 2015 16:55:16 +0200 Subject: [PATCH] Preparing release Gin v1.0rc1 --- CHANGELOG.md | 7 ++++++- examples/{example_basic.go => basic/main.go} | 2 +- gin.go | 2 ++ mode.go | 11 ++++++----- 4 files changed, 15 insertions(+), 7 deletions(-) rename examples/{example_basic.go => basic/main.go} (97%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fc548ec..886ad850 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,15 @@ #Changelog -###Gin 1.0 (...) +###Gin 1.0rc1 (May 22, 2015) - [PERFORMANCE] Zero allocation router - [PERFORMANCE] Faster JSON, XML and text rendering - [PERFORMANCE] Custom hand optimized HttpRouter for Gin - [PERFORMANCE] Misc code optimizations. Inlining, tail call optimizations +- [NEW] Built-in support for golang.org/x/net/context - [NEW] Any(path, handler). Create a route that matches any path - [NEW] Refactored rendering pipeline (faster and static typeded) +- [NEW] Refactored errors API - [NEW] IndentedJSON() prints pretty JSON - [NEW] Added gin.DefaultWriter - [NEW] UNIX socket support @@ -15,6 +17,8 @@ - [NEW] JSON validation using go-validate-yourself (very powerful options) - [NEW] Completed suite of unit tests - [NEW] HTTP streaming with c.Stream() +- [NEW] StaticFile() creates a router for serving just one file. +- [NEW] StaticFS() has an option to disable directory listing. - [NEW] StaticFS() for serving static files through virtual filesystems - [NEW] Server-Sent Events native support - [NEW] WrapF() and WrapH() helpers for wrapping http.HandlerFunc and http.Handler @@ -28,6 +32,7 @@ - [FIX] Redirect using built-in http.Redirect() - [FIX] Logger when printing the requested path - [FIX] Documentation typos +- [FIX] Context.Engine renamed to Context.engine - [FIX] Better debugging messages - [FIX] ErrorLogger - [FIX] Debug HTTP render diff --git a/examples/example_basic.go b/examples/basic/main.go similarity index 97% rename from examples/example_basic.go rename to examples/basic/main.go index 919580d8..80f2bd3c 100644 --- a/examples/example_basic.go +++ b/examples/basic/main.go @@ -45,7 +45,7 @@ func main() { Value string `json:"value" binding:"required"` } - if c.Bind(&json) { + if c.Bind(&json) == nil { DB[user] = json.Value c.JSON(200, gin.H{"status": "ok"}) } diff --git a/gin.go b/gin.go index cc27da80..570ac83a 100644 --- a/gin.go +++ b/gin.go @@ -15,6 +15,8 @@ import ( "github.com/gin-gonic/gin/render" ) +const Version = "v1.0rc1" + var default404Body = []byte("404 page not found") var default405Body = []byte("405 method not allowed") diff --git a/mode.go b/mode.go index 8c54fdb6..77265f81 100644 --- a/mode.go +++ b/mode.go @@ -5,12 +5,13 @@ package gin import ( + "io" "os" "github.com/mattn/go-colorable" ) -const GIN_MODE = "GIN_MODE" +const ENV_GIN_MODE = "GIN_MODE" const ( DebugMode string = "debug" @@ -23,16 +24,16 @@ const ( testCode = iota ) -var DefaultWriter = colorable.NewColorableStdout() +var DefaultWriter io.Writer = colorable.NewColorableStdout() var ginMode int = debugCode var modeName string = DebugMode func init() { - value := os.Getenv(GIN_MODE) - if len(value) == 0 { + mode := os.Getenv(ENV_GIN_MODE) + if len(mode) == 0 { SetMode(DebugMode) } else { - SetMode(value) + SetMode(mode) } }