mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-24 10:58:18 +08:00
Merge branch 'master' into BindQuery
This commit is contained in:
commit
97253b5b0e
@ -88,7 +88,6 @@ BenchmarkZeus_GithubAll | 2000 | 944234 | 300688 | 2648
|
|||||||
- [x] Battle tested
|
- [x] Battle tested
|
||||||
- [x] API frozen, new releases will not break your code.
|
- [x] API frozen, new releases will not break your code.
|
||||||
|
|
||||||
|
|
||||||
## Start using it
|
## Start using it
|
||||||
|
|
||||||
1. Download and install it:
|
1. Download and install it:
|
||||||
@ -141,6 +140,14 @@ $ curl https://raw.githubusercontent.com/gin-gonic/gin/master/examples/basic/mai
|
|||||||
$ go run main.go
|
$ go run main.go
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Build with [jsoniter](https://github.com/json-iterator/go)
|
||||||
|
|
||||||
|
Gin use `encoding/json` as default json package but you can change to [jsoniter](https://github.com/json-iterator/go) by build from other tags.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ go build -tags=jsoniter .
|
||||||
|
```
|
||||||
|
|
||||||
## API Examples
|
## API Examples
|
||||||
|
|
||||||
### Using GET, POST, PUT, PATCH, DELETE and OPTIONS
|
### Using GET, POST, PUT, PATCH, DELETE and OPTIONS
|
||||||
|
|||||||
@ -7,11 +7,10 @@ package binding
|
|||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/json-iterator/go"
|
"github.com/gin-gonic/gin/json"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
json = jsoniter.ConfigCompatibleWithStandardLibrary
|
|
||||||
EnableDecoderUseNumber = false
|
EnableDecoderUseNumber = false
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -9,11 +9,9 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
"github.com/json-iterator/go"
|
"github.com/gin-gonic/gin/json"
|
||||||
)
|
)
|
||||||
|
|
||||||
var json = jsoniter.ConfigCompatibleWithStandardLibrary
|
|
||||||
|
|
||||||
type ErrorType uint64
|
type ErrorType uint64
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin/json"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
17
json/json.go
Normal file
17
json/json.go
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// Copyright 2017 Bo-Yi Wu. All rights reserved.
|
||||||
|
// Use of this source code is governed by a MIT style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !jsoniter
|
||||||
|
|
||||||
|
package json
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
Marshal = json.Marshal
|
||||||
|
MarshalIndent = json.MarshalIndent
|
||||||
|
NewDecoder = json.NewDecoder
|
||||||
|
)
|
||||||
18
json/jsoniter.go
Normal file
18
json/jsoniter.go
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
// Copyright 2017 Bo-Yi Wu. All rights reserved.
|
||||||
|
// Use of this source code is governed by a MIT style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build jsoniter
|
||||||
|
|
||||||
|
package json
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/json-iterator/go"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
json = jsoniter.ConfigCompatibleWithStandardLibrary
|
||||||
|
Marshal = json.Marshal
|
||||||
|
MarshalIndent = json.MarshalIndent
|
||||||
|
NewDecoder = json.NewDecoder
|
||||||
|
)
|
||||||
@ -8,11 +8,9 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/json-iterator/go"
|
"github.com/gin-gonic/gin/json"
|
||||||
)
|
)
|
||||||
|
|
||||||
var json = jsoniter.ConfigCompatibleWithStandardLibrary
|
|
||||||
|
|
||||||
type JSON struct {
|
type JSON struct {
|
||||||
Data interface{}
|
Data interface{}
|
||||||
}
|
}
|
||||||
|
|||||||
6
vendor/vendor.json
vendored
6
vendor/vendor.json
vendored
@ -34,10 +34,10 @@
|
|||||||
"revisionTime": "2017-06-01T23:02:30Z"
|
"revisionTime": "2017-06-01T23:02:30Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "WFJPa8cL6nzQU3yA1iN+gmaqrSU=",
|
"checksumSHA1": "0e59uuETpidkmpaRwipQ8auqwhM=",
|
||||||
"path": "github.com/json-iterator/go",
|
"path": "github.com/json-iterator/go",
|
||||||
"revision": "4b33139ad07fda872cb378bb4218b2fab74ce62b",
|
"revision": "6b6938829d6156d7b9825f83eec757f0f571c981",
|
||||||
"revisionTime": "2017-07-12T09:56:51Z"
|
"revisionTime": "2017-07-18T14:19:52Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "9if9IBLsxkarJ804NPWAzgskIAk=",
|
"checksumSHA1": "9if9IBLsxkarJ804NPWAzgskIAk=",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user