mirror of
https://github.com/gin-gonic/gin.git
synced 2026-06-07 04:38:19 +08:00
Merge c140efece5887ac0040b496141870d364806667f into d5b353c5d5a560322e6d96121c814115562501f7
This commit is contained in:
commit
add4866073
13
README.md
13
README.md
@ -154,6 +154,7 @@ func main() {
|
|||||||
```
|
```
|
||||||
|
|
||||||
#### Querystring parameters
|
#### Querystring parameters
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func main() {
|
func main() {
|
||||||
router := gin.Default()
|
router := gin.Default()
|
||||||
@ -248,6 +249,7 @@ func main() {
|
|||||||
```
|
```
|
||||||
|
|
||||||
#### Grouping routes
|
#### Grouping routes
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func main() {
|
func main() {
|
||||||
router := gin.Default()
|
router := gin.Default()
|
||||||
@ -280,6 +282,7 @@ Use
|
|||||||
```go
|
```go
|
||||||
r := gin.New()
|
r := gin.New()
|
||||||
```
|
```
|
||||||
|
|
||||||
instead of
|
instead of
|
||||||
|
|
||||||
```go
|
```go
|
||||||
@ -288,6 +291,7 @@ r := gin.Default()
|
|||||||
|
|
||||||
|
|
||||||
#### Using middleware
|
#### Using middleware
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func main() {
|
func main() {
|
||||||
// Creates a router without any middleware by default
|
// Creates a router without any middleware by default
|
||||||
@ -373,7 +377,8 @@ func main() {
|
|||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
###Multipart/Urlencoded binding
|
### Multipart/Urlencoded binding
|
||||||
|
|
||||||
```go
|
```go
|
||||||
package main
|
package main
|
||||||
|
|
||||||
@ -451,7 +456,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
####Serving static files
|
#### Serving static files
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func main() {
|
func main() {
|
||||||
@ -465,7 +470,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
####HTML rendering
|
#### HTML rendering
|
||||||
|
|
||||||
Using LoadHTMLTemplates()
|
Using LoadHTMLTemplates()
|
||||||
|
|
||||||
@ -598,6 +603,7 @@ func main() {
|
|||||||
```
|
```
|
||||||
|
|
||||||
#### Using BasicAuth() middleware
|
#### Using BasicAuth() middleware
|
||||||
|
|
||||||
```go
|
```go
|
||||||
// simulate some private data
|
// simulate some private data
|
||||||
var secrets = gin.H{
|
var secrets = gin.H{
|
||||||
@ -637,6 +643,7 @@ func main() {
|
|||||||
|
|
||||||
|
|
||||||
#### Goroutines inside a middleware
|
#### 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.
|
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
|
```go
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user