Dmitry Kutakov
b52a1a1588
allow empty headers on DataFromReader ( #2121 )
2019-11-25 10:45:53 +08:00
thinkerou
2ee0e96394
Drop support go1.10 ( #2147 )
2019-11-24 23:07:56 +08:00
Ivan Chen
70ca31bc11
fix comment in `mode.go` ( #2129 )
...
EnableJsonDisallowUnknownFields => EnableJsonDecoderDisallowUnknownFields
2019-11-24 16:22:18 +08:00
thinkerou
15ced05c53
ready to release v1.5.0 ( #2109 )
...
* ready to release v1.5.0
* add some commit log
* Update CHANGELOG.md
Co-Authored-By: Dominik-K <dominik-k@mailbox.org>
* Update CHANGELOG.md
Co-Authored-By: Dominik-K <dominik-k@mailbox.org>
* Update CHANGELOG.md
Co-Authored-By: Dominik-K <dominik-k@mailbox.org>
* Update CHANGELOG.md
Co-Authored-By: Dominik-K <dominik-k@mailbox.org>
* Update CHANGELOG.md
Co-Authored-By: Dominik-K <dominik-k@mailbox.org>
* Update CHANGELOG.md
Co-Authored-By: Dominik-K <dominik-k@mailbox.org>
* Update CHANGELOG.md
Co-Authored-By: Dominik-K <dominik-k@mailbox.org>
* Update CHANGELOG.md
Co-Authored-By: Dominik-K <dominik-k@mailbox.org>
* Update CHANGELOG.md
Co-Authored-By: Dominik-K <dominik-k@mailbox.org>
* Update CHANGELOG.md
Co-Authored-By: Dominik-K <dominik-k@mailbox.org>
* Update CHANGELOG.md
Co-Authored-By: Dominik-K <dominik-k@mailbox.org>
* Update CHANGELOG.md
Co-Authored-By: Dominik-K <dominik-k@mailbox.org>
* Update CHANGELOG.md
Co-Authored-By: Dominik-K <dominik-k@mailbox.org>
* remove refactor and update readme pr
2019-11-24 10:25:21 +08:00
Dmitry Kutakov
db9174ae0c
fix ignore walking on form mapping ( #1942 ) ( #1943 )
2019-11-01 10:47:40 +08:00
linfangrong
0f951956d0
[FIX] c.Request.FormFile maybe file, need close ( #2114 )
2019-10-31 23:17:12 +08:00
Shamus Taylor
aabaccbba2
Close files opened in static file handler ( #2118 )
...
* Close files opened in static file handler
* Do not use defer
2019-10-31 22:52:02 +08:00
ishanray
517eacb4f9
Update gin.go ( #2110 )
2019-10-31 11:13:39 +08:00
Dmitry Kutakov
393a63f3b0
Fix 'errcheck' linter warnings ( #2093 )
2019-10-27 13:58:59 +08:00
ZhangYunHao
8a1bfcfd3b
format errUnknownType ( #2103 )
2019-10-26 14:20:35 +08:00
Ildar1111
089016a092
Update README.md ( #2106 )
...
* Update README.md
c:\>curl 0.0.0.0:8080
"Failed to connect to 0.0.0.0 port 8080: Address not available"
Connecting to address 0.0.0.0:8080 is not allowed on windows. From http://msdn.microsoft.com/en-us/library/aa923167.aspx
" ... If the address member of the structure specified by the name parameter is
all zeroes, connect will return the error WSAEADDRNOTAVAIL. ..."
* Update README.md
edit comment
2019-10-25 10:03:53 +08:00
willnewrelic
0ce4661029
Use Writer in Context.Status ( #1606 )
2019-10-17 10:14:44 +08:00
Dmitry Kutakov
1a1cf655bd
add details in issue template ( #2085 )
...
indirectly request more details
2019-10-15 14:25:55 +08:00
Dmitry Kutakov
3cea16cc6c
Update go.sum file ( #2094 )
2019-10-15 11:04:25 +08:00
Dmitry Kutakov
f7becac7bc
Relocate binding body tests ( #2086 )
...
* Relocate binding body tests
Every test file should be related to a tested file.
Remove useless tests.
* Add github.com/stretchr/testify/require package
2019-10-10 16:58:31 +08:00
John Bampton
4fd3234840
Fix spelling. ( #2080 )
2019-10-03 07:46:41 +08:00
John Bampton
beb879e475
Change Writter to Writer. ( #2079 )
2019-09-30 14:22:12 +08:00
Manjusaka
79840bc1c6
support run HTTP server with specific net.Listener ( #2023 )
2019-09-30 09:12:22 +08:00
bullgare
9b9f4fab34
Updated Readme.md: file.Close() for template read ( #2068 )
2019-09-24 22:18:41 +08:00
Gaozhen Ying
d6eafcf48a
add TestDisableBindValidation ( #2071 )
2019-09-24 21:44:15 +08:00
Santhosh Kumar
2e5a7196cc
use url.URL.Query instead of parsing query ( #2063 )
2019-09-24 10:01:57 +08:00
bullgare
f45c83c70c
Updated Readme.md for serving multiple services ( #2067 )
...
Previous version had issues - if one service did not start for any reason, you would never know about it.
2019-09-23 23:48:10 +08:00
thinkerou
0b96dd8ae5
chore: remove env var for go master branch ( #2056 )
2019-09-22 15:35:34 +08:00
ZYunH
b562fed3aa
Make countParams more readable ( #2052 )
2019-09-11 18:10:39 +08:00
Gaozhen Ying
9aa870f108
Adjust Render.Redirect test case ( #2053 )
2019-09-10 17:16:37 +08:00
Panmax
b8b2fada5c
fix GetPostFormMap ( #2051 )
2019-09-10 14:32:30 +08:00
Krzysztof Szafrański
f38c30a0d2
feat(binding): add DisallowUnknownFields() in gin.Context.BindJSON() ( #2028 )
2019-09-06 13:56:59 +08:00
Jim Filippou
b80d675864
Added specific installation instructions for Mac ( #2011 )
...
Made it more clear for Mac users using Go version 1.8 and greater.
2019-09-05 21:50:54 +08:00
thinkerou
1acb3fb30a
upgrade validator version to v9 ( #1015 )
...
* upgrade validator version to v9
* Update vendor.json
* Update go.mod
* Update go.sum
* fix
* fix
* fix bug
* Update binding_test.go
* Update validate_test.go
* Update go.sum
* Update go.mod
* Update go.sum
* Update go.mod
* Update go.sum
2019-09-05 21:39:56 +08:00
thinkerou
c3f7fc399a
chore: support go1.13 ( #2038 )
...
* chore: support go1.13
* chore: remove env var for go1.13
2019-09-04 12:26:50 +08:00
George Gabolaev
01ca625b98
Fixed JSONP format (added semicolon) ( #2007 )
...
* Fixed JSONP format (added semicolon)
* render_test fix
2019-09-02 20:18:08 +08:00
Johnny Dallas
6ece26c7c5
Add Header bind methods to README ( #2025 )
2019-08-30 10:58:55 +08:00
Shuo
a22377b09b
logger_test: color ( #1926 )
...
* logger color: string literals
* logger_test: color
2019-08-29 08:32:22 +08:00
Carlos Eduardo
9a820cf005
Bump github.com/mattn/go-isatty library to support Risc-V ( #2019 )
...
Signed-off-by: CarlosEDP <me@carlosedp.com>
2019-08-16 09:10:44 +08:00
Andrew Szeto
5612cadb73
Remove unused code ( #2013 )
2019-08-10 09:26:58 +08:00
Segev Finer
20440b96b9
Support negative Content-Length in DataFromReader ( #1981 )
...
You can get an http.Response with ContentLength set to -1 (Chunked encoding), so
for DataFromReader to be useful for those we need to support that.
2019-08-05 09:42:59 +08:00
Christian Muehlhaeuser
461df9320a
Simplify code ( #2004 )
...
- Use buf.String instead of converison
- Remove redundant return
2019-07-27 09:06:37 +08:00
guonaihong
502c898d75
binding: support unix time ( #1980 )
...
* binding: support unix time
ref:#1979
* binding: support unix time
add test file
modify readme
```golang
package main
import (
"fmt"
"github.com/gin-gonic/gin"
"time"
)
type shareTime struct {
CreateTime time.Time `form:"createTime" time_format:"unixNano"`
UnixTime time.Time `form:"unixTime" time_format:"unix"`
}
func main() {
r := gin.Default()
unix := r.Group("/unix")
testCT := time.Date(2019, 7, 6, 16, 0, 33, 123, time.Local)
fmt.Printf("%d\n", testCT.UnixNano())
testUT := time.Date(2019, 7, 6, 16, 0, 33, 0, time.Local)
fmt.Printf("%d\n", testUT.Unix())
unix.GET("/nano", func(c *gin.Context) {
s := shareTime{}
c.ShouldBindQuery(&s)
if !testCT.Equal(s.CreateTime) {
c.String(500, "want %d got %d", testCT.UnixNano(), s.CreateTime)
return
}
c.JSON(200, s)
})
unix.GET("/sec", func(c *gin.Context) {
s := shareTime{}
c.ShouldBindQuery(&s)
if !testUT.Equal(s.UnixTime) {
c.String(500, "want %d got %d", testCT.Unix(), s.UnixTime)
return
}
c.JSON(200, s)
})
r.Run()
}
```
* Contraction variable scope
2019-07-10 13:02:40 +08:00
thinkerou
0349de518b
upgrade github.com/ugorji/go/codec ( #1969 )
2019-07-10 06:20:20 +08:00
Rafal Zajac
e602d524cc
Typo ( #1971 )
2019-07-04 07:57:52 +08:00
Alan Wang
6f7276fdc1
Update CHANGELOG.md ( #1966 )
...
typo fix
2019-06-30 08:55:09 +08:00
guonaihong
b67bc8f005
Gin1.5 bytes.Buffer to strings.Builder ( #1939 )
...
* Replace bytes.Buffer to strings.Builder
* Merge the latest changes
* Update errors.go
2019-06-29 20:43:32 +08:00
thinkerou
3f53a58d4a
Add user case: brigade ( #1937 )
2019-06-29 00:09:53 +08:00
bbiao
f65018d7b1
Bugfix for the FullPath feature ( #1919 )
...
* worked with more complex situations
* the original pr not work when and a short route with the same prefix
to some already added routes
2019-06-28 23:54:52 +08:00
Dan Markham
fc920dc561
Drop Support for go1.8 and go1.9 ( #1933 )
2019-06-28 23:43:07 +08:00
srt180
46acb91996
modify readme example code ( #1961 )
2019-06-28 09:34:14 +08:00
guonaihong
31342fc03f
fix README.md code bug and Change map to gin.H ( #1963 )
...
``` go
func main() {
r := gin.Default()
// r.GET("/JSONP?callback=x", func(c *gin.Context) { // old
r.GET("/JSONP", func(c *gin.Context) { // new
data := gin.H{
"foo": "bar",
}
//callback is x
// Will output : x({\"foo\":\"bar\"})
c.JSONP(http.StatusOK, data)
})
// Listen and serve on 0.0.0.0:8080
r.Run(":8080")
}
// client
// curl http://127.0.0.1:8080/JSONP?callback=x
// old output
// 404 page not found
// new output
// x({"foo":"bar"})
```
Most of the sample code in the documentation map[string]interface{} is represented by gin.H.
gin.H is a very important place for me to like gin, can write a lot less code
2019-06-28 09:25:19 +08:00
guonaihong
f98b339b77
support bind http header param #1956 ( #1957 )
...
* support bind http header param #1956
update #1956
```
package main
import (
"fmt"
"github.com/gin-gonic/gin"
)
type testHeader struct {
Rate int `header:"Rate"`
Domain string `header:"Domain"`
}
func main() {
r := gin.Default()
r.GET("/", func(c *gin.Context) {
h := testHeader{}
if err := c.ShouldBindHeader(&h); err != nil {
c.JSON(200, err)
}
fmt.Printf("%#v\n", h)
c.JSON(200, gin.H{"Rate": h.Rate, "Domain": h.Domain})
})
r.Run()
// client
// curl -H "rate:300" -H "domain:music" 127.0.0.1:8080/
// output
// {"Domain":"music","Rate":300}
}
```
* add unit test
* Modify the code to get the http header
When the http header is obtained in the standard library,
the key value will be modified by the CanonicalMIMEHeaderKey function,
and finally the value of the http header will be obtained from the map.
As follows.
```go
func (h MIMEHeader) Get(key string) string {
// ...
v := h[CanonicalMIMEHeaderKey(key)]
// ...
}
```
This pr also follows this modification
* Thanks to vkd for suggestions, modifying code
* Increase test coverage
env GOPATH=`pwd` go test github.com/gin-gonic/gin/binding -coverprofile=cover.prof
ok github.com/gin-gonic/gin/binding 0.015s coverage: 100.0% of statements
* Rollback check code
* add use case to README.md
2019-06-27 12:47:45 +08:00
Dmitry Kutakov
09a3650c97
binding: add support of multipart multi files ( #1878 ) ( #1949 )
...
* binding: add support of multipart multi files (#1878 )
* update readme: add multipart file binding
2019-06-18 19:49:10 +08:00
田欧
75b9d2bed7
Attempt to fix PostForm cache bug ( #1931 )
2019-06-12 21:07:15 +08:00