mirror of
https://github.com/gin-gonic/gin.git
synced 2026-01-11 00:56:57 +08:00
Merge 39c00aa8a188d97d36409c9ad94980a38e4015a7 into e2212d40c62a98b388a5eb48ecbdcf88534688ba
This commit is contained in:
commit
00e6237b49
20
README.md
20
README.md
@ -1,5 +1,4 @@
|
||||
|
||||
#Gin Web Framework
|
||||
# Gin Web Framework
|
||||
|
||||
<img align="right" src="https://raw.githubusercontent.com/gin-gonic/gin/master/logo.jpg">
|
||||
[](https://travis-ci.org/gin-gonic/gin)
|
||||
@ -81,7 +80,6 @@ BenchmarkZeus_GithubAll | 2000 | 944234 | 300688 | 2648
|
||||
- [x] Battle tested
|
||||
- [x] API frozen, new releases will not break your code.
|
||||
|
||||
|
||||
## Start using it
|
||||
|
||||
1. Download and install it:
|
||||
@ -153,6 +151,7 @@ func main() {
|
||||
```
|
||||
|
||||
#### Querystring parameters
|
||||
|
||||
```go
|
||||
func main() {
|
||||
router := gin.Default()
|
||||
@ -247,6 +246,7 @@ func main() {
|
||||
```
|
||||
|
||||
#### Grouping routes
|
||||
|
||||
```go
|
||||
func main() {
|
||||
router := gin.Default()
|
||||
@ -285,8 +285,8 @@ instead of
|
||||
r := gin.Default()
|
||||
```
|
||||
|
||||
|
||||
#### Using middleware
|
||||
|
||||
```go
|
||||
func main() {
|
||||
// Creates a router without any middleware by default
|
||||
@ -371,8 +371,8 @@ func main() {
|
||||
}
|
||||
```
|
||||
|
||||
### Multipart/Urlencoded binding
|
||||
|
||||
###Multipart/Urlencoded binding
|
||||
```go
|
||||
package main
|
||||
|
||||
@ -410,7 +410,6 @@ Test it with:
|
||||
$ curl -v --form user=user --form password=password http://localhost:8080/login
|
||||
```
|
||||
|
||||
|
||||
#### XML, JSON and YAML rendering
|
||||
|
||||
```go
|
||||
@ -450,7 +449,7 @@ func main() {
|
||||
}
|
||||
```
|
||||
|
||||
####Serving static files
|
||||
#### Serving static files
|
||||
|
||||
```go
|
||||
func main() {
|
||||
@ -464,7 +463,7 @@ func main() {
|
||||
}
|
||||
```
|
||||
|
||||
####HTML rendering
|
||||
#### HTML rendering
|
||||
|
||||
Using LoadHTMLTemplates()
|
||||
|
||||
@ -543,7 +542,6 @@ func main() {
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
#### Redirects
|
||||
|
||||
Issuing a HTTP redirect is easy:
|
||||
@ -597,6 +595,7 @@ func main() {
|
||||
```
|
||||
|
||||
#### Using BasicAuth() middleware
|
||||
|
||||
```go
|
||||
// simulate some private data
|
||||
var secrets = gin.H{
|
||||
@ -634,8 +633,8 @@ func main() {
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
#### Goroutines inside a middleware
|
||||
|
||||
When starting inside a middleware or handler, you **SHOULD NOT** use the original context inside it, you have to use a read-only copy.
|
||||
|
||||
```go
|
||||
@ -731,3 +730,4 @@ Awesome project lists using [Gin](https://github.com/gin-gonic/gin) web framewor
|
||||
|
||||
* [drone](https://github.com/drone/drone): Drone is a Continuous Delivery platform built on Docker, written in Go
|
||||
* [gorush](https://github.com/appleboy/gorush): A push notification server written in Go.
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user