Skip to content

Commit

Permalink
Merge branch 'develop' | Update AUTHORS and CHANGELOG
Browse files Browse the repository at this point in the history
  • Loading branch information
javierprovecho committed Feb 4, 2015
2 parents 28b9ff9 + d936320 commit 5cfe2c5
Show file tree
Hide file tree
Showing 21 changed files with 839 additions and 331 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
language: go

sudo: false
go:
- 1.3
- 1.4
- tip
58 changes: 54 additions & 4 deletions AUTHORS.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
List of all the awesome people working to make Gin the best Web Framework in Go!
List of all the awesome people working to make Gin the best Web Framework in Go.



##gin 0.x series authors

**Lead Developer:** Manu Martinez-Almeida (@manucorporat)
**Staff:**
Javier Provecho (@javierprovecho)
**Original Developer:** Manu Martinez-Almeida (@manucorporat)
**Long-term Maintainer:** Javier Provecho (@javierprovecho)

People and companies, who have contributed, in alphabetical order.

Expand All @@ -31,6 +30,14 @@ People and companies, who have contributed, in alphabetical order.
- Added travis CI integration


**@andredublin (Andre Dublin)**
- Fix typo in comment


**@bredov (Ludwig Valda Vasquez)**
- Fix html templating in debug mode


**@bluele (Jun Kimura)**
- Fixes code examples in README

Expand All @@ -41,20 +48,38 @@ People and companies, who have contributed, in alphabetical order.

**@dickeyxxx (Jeff Dickey)**
- Typos in README
- Add example about serving static files


**@dutchcoders (DutchCoders)**
- ★ Fix security bug that allows client to spoof ip
- Fix typo. r.HTMLTemplates -> SetHTMLTemplate


**@fmd (Fareed Dudhia)**
- Fix typo. SetHTTPTemplate -> SetHTMLTemplate


**@jammie-stackhouse (Jamie Stackhouse)
- Add more shortcuts for router methods


**@jasonrhansen**
- Fix spelling and grammar errors in documentation


**@JasonSoft (Jason Lee)**
- Fix typo in comment


**@julienschmidt (Julien Schmidt)**
- gofmt the code examples


**@kelcecil (Kel Cecil)**
- Fix readme typo


**@kyledinh (Kyle Dinh)**
- Adds RunTLS()

Expand All @@ -63,6 +88,10 @@ People and companies, who have contributed, in alphabetical order.
- Small fixes in README


**@loongmxbt (Saint Asky)**
- Fix typo in example


**@lucas-clemente (Lucas Clemente)**
- ★ work around path.Join removing trailing slashes from routes

Expand All @@ -73,10 +102,15 @@ People and companies, who have contributed, in alphabetical order.
- Fixes Content-Type for json render


**@mirzac (Mirza Ceric)**
- Fix debug printing


**@mopemope (Yutaka Matsubara)**
- ★ Adds Godep support (Dependencies Manager)
- Fix variadic parameter in the flexible render API
- Fix Corrupted plain render
- Add Pluggable View Renderer Example


**@msemenistyi (Mykyta Semenistyi)**
Expand All @@ -96,6 +130,10 @@ People and companies, who have contributed, in alphabetical order.
- Fix Port usage in README.


**@se77en (Damon Zhao)**
- Improve color logging


**@silasb (Silas Baronda)**
- Fixing quotes in README

Expand All @@ -104,5 +142,17 @@ People and companies, who have contributed, in alphabetical order.
- Fixes some texts in README II


**@slimmy (Jimmy Pettersson)
- Added messages for required bindings


**@smira (Andrey Smirnov)**
- Add support for ignored/unexported fields in binding


**@yosssi (Keiji Yoshida)**
- Fix link in README


**@yuyabee**
- Fixed README
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
#Changelog

###Gin 0.5 (Jan 4, 2015)

- [NEW] Content Negotiation
- [FIX] Solved security bug that allow a client to spoof ip
- [FIX] Fix unexported/ignored fields in binding


###Gin 0.4 (Aug 21, 2014)

- [NEW] Development mode
Expand Down Expand Up @@ -34,7 +41,7 @@
- [NEW] New API for serving static files. gin.Static()
- [NEW] gin.H() can be serialized into XML
- [NEW] Typed errors. Errors can be typed. Internet/external/custom.
- [NEW] Support for Godebs
- [NEW] Support for Godeps
- [NEW] Travis/Godocs badges in README
- [NEW] New Bind() and BindWith() methods for parsing request body.
- [NEW] Add Content.Copy()
Expand Down
2 changes: 1 addition & 1 deletion Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

71 changes: 59 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,35 @@
[![GoDoc](https://godoc.org/github.com/gin-gonic/gin?status.svg)](https://godoc.org/github.com/gin-gonic/gin)
[![Build Status](https://travis-ci.org/gin-gonic/gin.svg)](https://travis-ci.org/gin-gonic/gin)

Gin is a web framework written in Golang. It features a martini-like API with much better performance, up to 40 times faster. If you need performance and good productivity, you will love Gin.
![Gin console logger](http://gin-gonic.github.io/gin/other/console.png)
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.

![Gin console logger](https://gin-gonic.github.io/gin/other/console.png)

```
$ cat test.go
```
```go
package main

import "github.com/gin-gonic/gin"

func main() {
router := gin.Default()
router.GET("/", func(c *gin.Context) {
c.String(200, "hello world")
})
router.GET("/ping", func(c *gin.Context) {
c.String(200, "pong")
})
router.POST("/submit", func(c *gin.Context) {
c.String(401, "not authorized")
})
router.PUT("/error", func(c *gin.Context) {
c.String(500, "and error hapenned :(")
})
router.Run(":8080")
}
```

##Gin is new, will it be supported?

Expand All @@ -24,19 +51,19 @@ Yes, Gin is an internal project of [my](https://github.com/manucorporat) upcomin
- [x] Flexible rendering system
- [ ] More powerful validation API
- [ ] Improve documentation
- [ ] Add more cool middlewares, for example redis caching (this also helps developers to understand the framework).
- [X] Add more cool middlewares, for example redis caching (this also helps developers to understand the framework).
- [x] Continuous integration



## Start using it
Obviously, you need to have Git and Go! already installed to run Gin.
Obviously, you need to have Git and Go already installed to run Gin.
Run this in your terminal

```
go get github.com/gin-gonic/gin
```
Then import it in your Go! code:
Then import it in your Go code:

```
import "github.com/gin-gonic/gin"
Expand Down Expand Up @@ -223,7 +250,7 @@ func main() {
r := gin.Default()

// Example for binding JSON ({"user": "manu", "password": "123"})
r.POST("/login", func(c *gin.Context) {
r.POST("/loginJSON", func(c *gin.Context) {
var json LoginJSON

c.Bind(&json) // This will infer what binder to use depending on the content-type header.
Expand All @@ -234,8 +261,8 @@ func main() {
}
})

// Example for binding a HTLM form (user=manu&password=123)
r.POST("/login", func(c *gin.Context) {
// Example for binding a HTML form (user=manu&password=123)
r.POST("/loginHTML", func(c *gin.Context) {
var form LoginForm

c.BindWith(&form, binding.Form) // You can also specify which binder to use. We support binding.Form, binding.JSON and binding.XML.
Expand All @@ -257,7 +284,7 @@ func main() {
func main() {
r := gin.Default()

// gin.H is a shortcup for map[string]interface{}
// gin.H is a shortcut for map[string]interface{}
r.GET("/someJSON", func(c *gin.Context) {
c.JSON(200, gin.H{"message": "hey", "status": 200})
})
Expand Down Expand Up @@ -286,6 +313,21 @@ func main() {
}
```

####Serving static files

Use Engine.ServeFiles(path string, root http.FileSystem):

```go
func main() {
r := gin.Default()
r.Static("/assets", "./assets")

// Listen and server on 0.0.0.0:8080
r.Run(":8080")
}
```

Note: this will use `httpNotFound` instead of the Router's `NotFound` handler.

####Serving static files

Expand All @@ -310,7 +352,7 @@ Using LoadHTMLTemplates()
```go
func main() {
r := gin.Default()
r.LoadHTMLTemplates("templates/*")
r.LoadHTMLGlob("templates/*")
r.GET("/index", func(c *gin.Context) {
obj := gin.H{"title": "Main website"}
c.HTML(200, "index.tmpl", obj)
Expand All @@ -320,6 +362,11 @@ func main() {
r.Run(":8080")
}
```
```html
<h1>
{{ .title }}
</h1>
```

You can also use your own html template render

Expand All @@ -329,7 +376,7 @@ import "html/template"
func main() {
r := gin.Default()
html := template.Must(template.ParseFiles("file1", "file2"))
r.HTMLTemplates = html
r.SetHTMLTemplate(html)

// Listen and server on 0.0.0.0:8080
r.Run(":8080")
Expand Down Expand Up @@ -413,7 +460,7 @@ func main() {
// hit "localhost:8080/admin/secrets
authorized.GET("/secrets", func(c *gin.Context) {
// get user, it was setted by the BasicAuth middleware
user := c.Get(gin.AuthUserKey).(string)
user := c.MustGet(gin.AuthUserKey).(string)
if secret, ok := secrets[user]; ok {
c.JSON(200, gin.H{"user": user, "secret": secret})
} else {
Expand Down
Loading

0 comments on commit 5cfe2c5

Please sign in to comment.