v0.5 release
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Javier Provecho Fernandez · committed by Javier Provecho Fernandez · parents 5cfe2c5, b1758d3 · Browse files · 8 files·+62 added−42 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
8 files+62 added−42 removed
- other:+62 added−42 removed
Provenance
- Commit
50e7e42- Tree
3060e6d- Author
Javier Provecho Fernandez <javiertitan@gmail.com>- Committer
Javier Provecho Fernandez <javiertitan@gmail.com>- Parent 1
5cfe2c5- Parent 2
b1758d3
8 files changed+62 added−42 removed
modified:binding/binding.go+1 added-1 removed
168 unmodified lines169 for i := 0; i < typ.NumField(); i++ {170 field := typ.Field(i)171 172 // Allow ignored and unexported fields in the struct173- if field.Tag.Get("form") == "-" || field.PkgPath != "" {173+ if len(field.PkgPath) > 0 || field.Tag.Get("form") == "-" {174 continue175 }176 177 fieldValue := val.Field(i).Interface()39 unmodified linesmodified:Godeps/Godeps.json+1 added-1 removed
2 unmodified lines34567789102 unmodified lines "GoVersion": "go1.3", "Deps": [ { "ImportPath": "github.com/julienschmidt/httprouter", "Rev": "aeec11926f7a8fab580383810e1b1bbba99bdaa7" "Rev": "00ce1c6a267162792c367acc43b1681a884e1872" } ]}modified:render/render.go+1 added-1 removed
48 unmodified lines49 HTMLDebug = &htmlDebugRender{}50 )51 52 func writeHeader(w http.ResponseWriter, code int, contentType string) {53- w.Header().Set("Content-Type", contentType)53+ w.Header().Set("Content-Type", contentType+"; charset=utf-8")54 w.WriteHeader(code)55 }56 57 func (_ jsonRender) Render(w http.ResponseWriter, code int, data ...interface{}) error {66 unmodified linesmodified:AUTHORS.md+18 added-2 removed
7 unmodified lines891011121314151617181943 unmodified lines636465666367686970713 unmodified lines75767778798081828384858650 unmodified lines1371381391401411421431441451461471484 unmodified lines1531541551561451571581591601611621631641651661671681691701711722 unmodified lines7 unmodified lines**Long-term Maintainer:** Javier Provecho (@javierprovecho)
People and companies, who have contributed, in alphabetical order.
**@achedeuzot (Klemen Sever)**- Fix newline debug printing
**@adammck (Adam Mckaig)**- Add MIT license
43 unmodified lines**@fmd (Fareed Dudhia)**- Fix typo. SetHTTPTemplate -> SetHTMLTemplate
**@jammie-stackhouse (Jamie Stackhouse)**@jammie-stackhouse (Jamie Stackhouse)**- Add more shortcuts for router methods
**@jasonrhansen**3 unmodified lines**@JasonSoft (Jason Lee)**- Fix typo in comment
**@joiggama (Ignacio Galindo)**- Add utf-8 charset header on renders
**@julienschmidt (Julien Schmidt)**- gofmt the code examples
50 unmodified lines**@r8k (Rajiv Kilaparti)**- Fix Port usage in README.
**@RobAWilkinson (Robert Wilkinson)**- Add example of forms and params
**@se77en (Damon Zhao)**- Improve color logging
4 unmodified lines**@SkuliOskarsson (Skuli Oskarsson)**- Fixes some texts in README II
**@slimmy (Jimmy Pettersson)**@slimmy (Jimmy Pettersson)**- Added messages for required bindings
**@smira (Andrey Smirnov)**- Add support for ignored/unexported fields in binding
**@superalsrk (SRK.Lyu)**- Update httprouter godeps
**@yosssi (Keiji Yoshida)**- Fix link in README
2 unmodified linesmodified:CHANGELOG.md+4 added-1 removed
1 #Changelog2 3-###Gin 0.5 (Jan 4, 2015)3+###Gin 0.6 (Mar 7, 2015)4 5+6+###Gin 0.5 (Feb 7, 2015)7+8 - [NEW] Content Negotiation9 - [FIX] Solved security bug that allow a client to spoof ip10 - [FIX] Fix unexported/ignored fields in binding11 53 unmodified linesmodified:context_test.go+6 added-6 removed
74 unmodified lines75 if w.Body.String() != "{\"foo\":\"bar\"}\n" {76 t.Errorf("Response should be {\"foo\":\"bar\"}, was: %s", w.Body.String())77 }78 79- if w.HeaderMap.Get("Content-Type") != "application/json" {79+ if w.HeaderMap.Get("Content-Type") != "application/json; charset=utf-8" {80 t.Errorf("Content-Type should be application/json, was %s", w.HeaderMap.Get("Content-Type"))81 }82 }83 18 unmodified lines102 if w.Body.String() != "Hello alexandernyquist" {103 t.Errorf("Response should be Hello alexandernyquist, was: %s", w.Body.String())104 }105 106- if w.HeaderMap.Get("Content-Type") != "text/html" {106+ if w.HeaderMap.Get("Content-Type") != "text/html; charset=utf-8" {107 t.Errorf("Content-Type should be text/html, was %s", w.HeaderMap.Get("Content-Type"))108 }109 }110 13 unmodified lines124 if w.Body.String() != "test" {125 t.Errorf("Response should be test, was: %s", w.Body.String())126 }127 128- if w.HeaderMap.Get("Content-Type") != "text/plain" {128+ if w.HeaderMap.Get("Content-Type") != "text/plain; charset=utf-8" {129 t.Errorf("Content-Type should be text/plain, was %s", w.HeaderMap.Get("Content-Type"))130 }131 }132 13 unmodified lines146 if w.Body.String() != "<map><foo>bar</foo></map>" {147 t.Errorf("Response should be <map><foo>bar</foo></map>, was: %s", w.Body.String())148 }149 150- if w.HeaderMap.Get("Content-Type") != "application/xml" {150+ if w.HeaderMap.Get("Content-Type") != "application/xml; charset=utf-8" {151 t.Errorf("Content-Type should be application/xml, was %s", w.HeaderMap.Get("Content-Type"))152 }153 }154 180 unmodified lines335 if w.Body.String() != "{\"parsed\":\"bar\"}\n" {336 t.Errorf("Response should be {\"parsed\":\"bar\"}, was: %s", w.Body.String())337 }338 339- if w.HeaderMap.Get("Content-Type") != "application/json" {339+ if w.HeaderMap.Get("Content-Type") != "application/json; charset=utf-8" {340 t.Errorf("Content-Type should be application/json, was %s", w.HeaderMap.Get("Content-Type"))341 }342 }343 24 unmodified lines368 if w.Body.String() != "{\"parsed\":\"嘉\"}\n" {369 t.Errorf("Response should be {\"parsed\":\"嘉\"}, was: %s", w.Body.String())370 }371 372- if w.HeaderMap.Get("Content-Type") != "application/json" {372+ if w.HeaderMap.Get("Content-Type") != "application/json; charset=utf-8" {373 t.Errorf("Content-Type should be application/json, was %s", w.HeaderMap.Get("Content-Type"))374 }375 }376 107 unmodified linesmodified:gin.go+2 added-2 removed
125 unmodified lines126 engine.router.ServeHTTP(writer, request)127 }128 129 func (engine *Engine) Run(addr string) error {130- debugPrint("Listening and serving HTTP on %s", addr)130+ debugPrint("Listening and serving HTTP on %s\n", addr)131 if err := http.ListenAndServe(addr, engine); err != nil {132 return err133 }134 return nil135 }136 137 func (engine *Engine) RunTLS(addr string, cert string, key string) error {138- debugPrint("Listening and serving HTTPS on %s", addr)138+ debugPrint("Listening and serving HTTPS on %s\n", addr)139 if err := http.ListenAndServeTLS(addr, cert, key, engine); err != nil {140 return err141 }142 return nil1 unmodified linemodified:README.md+29 added-28 removed
1-#Gin Web Framework1+#Gin Web Framework [](https://godoc.org/github.com/gin-gonic/gin) [](https://travis-ci.org/gin-gonic/gin)2 3-[](https://godoc.org/github.com/gin-gonic/gin)4-[](https://travis-ci.org/gin-gonic/gin)5-3 Gin is a web framework written in Golang. It features a martini-like API with much better performance, up to 40 times faster thanks to [httprouter](https://github.com/julienschmidt/httprouter). If you need performance and good productivity, you will love Gin. 4 5 6 24 unmodified lines31 ```32 33 ##Gin is new, will it be supported?34 38-Yes, Gin is an internal project of [my](https://github.com/manucorporat) upcoming startup. We developed it and we are going to continue using and improve it.35+Yes, Gin is an internal tool of [Manu](https://github.com/manucorporat) and [Javi](https://github.com/javierprovecho) for many of our projects/start-ups. We developed it and we are going to continue using and improve it.36 37 38 ##Roadmap for v1.042-- [x] Performance improments, reduce allocation and garbage collection overhead43-- [x] Fix bugs44-- [ ] Stable API39 - [ ] Ask our designer for a cool logo40 - [ ] Add tons of unit tests41 - [ ] Add internal benchmarks suite42+- [ ] More powerful validation API43+- [ ] Improve documentation44+- [ ] Add Swagger support45+- [x] Stable API46 - [x] Improve logging system47 - [x] Improve JSON/XML validation using bindings48 - [x] Improve XML support49 - [x] Flexible rendering system52-- [ ] More powerful validation API53-- [ ] Improve documentation54-- [X] Add more cool middlewares, for example redis caching (this also helps developers to understand the framework).50+- [x] Add more cool middlewares, for example redis caching (this also helps developers to understand the framework).51 - [x] Continuous integration52+- [x] Performance improments, reduce allocation and garbage collection overhead53+- [x] Fix bugs54 55 56 57 ## Start using it72 unmodified lines130 message := "Hello "+name131 c.String(200, message)132 })133 136- // However, this one will match /user/john and also /user/john/send134+ // However, this one will match /user/john/ and also /user/john/send135+ // If no other routers match /user/john, it will redirect to /user/join/136 r.GET("/user/:name/*action", func(c *gin.Context) {137 name := c.Params.ByName("name")138 action := c.Params.ByName("action")139 message := name + " is " + action3 unmodified lines143 // Listen and server on 0.0.0.0:8080144 r.Run(":8080")145 }146 ```147+###Form parameters148+```go149+func main() {150+ r := gin.Default()151+ 152+ // This will respond to urls like search?firstname=Jane&lastname=Doe153+ r.GET("/search", func(c *gin.Context) {154+ // You need to call ParseForm() on the request to receive url and form params first155+ c.Request.ParseForm()156+ 157+ firstname := c.Request.Form.Get("firstname")158+ lastname := c.Request.Form.get("lastname")159 160+ message := "Hello "+ firstname + lastname161+ c.String(200, message)162+ })163+ r.Run(":8080")164+}165+```166 167 #### Grouping routes168 ```go169 func main() {175 unmodified lines345 ```346 347 Note: this will use `httpNotFound` instead of the Router's `NotFound` handler.348 332-####Serving static files333-334-Use Engine.ServeFiles(path string, root http.FileSystem):335-336-```go337-func main() {338- r := gin.Default()339- r.Static("/assets", "./assets")340-341- // Listen and server on 0.0.0.0:8080342- r.Run(":8080")343-}344-```345-346-Note: this will use `httpNotFound` instead of the Router's `NotFound` handler.347-349 ####HTML rendering350 351 Using LoadHTMLTemplates()352 184 unmodified lines