Commit Graph

1360 Commits

Author SHA1 Message Date
Bo-Yi Wu 6655232d45
Merge branch 'master' into fix-binding-empty-value 2020-03-18 21:21:53 +08:00
AcoNCodes 73ccfea3ba
Add mutex for protect Context.Keys map (#1391)
* Add mutex for protect Context.Keys map

* Fix tests

Co-authored-by: Nikolay Tolkachov <nik.tolkachov@gmail.com>
Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2020-03-17 00:52:02 +08:00
Ryan J. Yoder 67008be35f
Unix Socket Handling (#2280)
* do not set unix socket permissions. Cleanup unix socket.

* removed useless error checking
2020-03-16 22:36:15 +08:00
Manuel Alonso a71af9c144
removing log injection (#2277)
Co-authored-by: thinkerou <thinkerou@gmail.com>
2020-03-07 21:51:33 +08:00
Nikifor Seryakov 1d055af1bc
FileFromFS (#2112)
* Context.FileFromFS added

* Context File and FileFromFS examples at README

Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2020-03-07 10:23:33 +08:00
kebo 2ff2b19e14
fix accept incoming network connections (#2216) 2020-03-07 09:21:02 +08:00
thinkerou 094b3fdb39
ci support go1.14 (#2262) 2020-02-26 10:27:03 +08:00
Kaushik Neelichetty 5f56109bcf
Use json marshall in context json to fix breaking new line issue. Fixes #2209 (#2228)
* ignore IntelliJ idea generated files

* update JSON renderer to use Marshall() instead of Encode(). Fix #2209

* Revert "ignore IntelliJ idea generated files"

This reverts commit e7bd017227.

Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
Co-authored-by: thinkerou <thinkerou@gmail.com>
2020-02-21 17:15:17 +08:00
Bo-Yi Wu 863ad2d4de
docs(badge): add todo badge (#2240)
fix https://github.com/gin-gonic/gin/issues/2236

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2020-02-21 16:33:36 +08:00
thinkerou 0d12918b0a
chore: upgrade depend version (#2231) 2020-02-13 20:23:29 +08:00
thinkerou acac7b1210
tree: range over nodes values (#2229) 2020-02-09 10:46:22 +08:00
Erik Bender 731c827892
add yaml negotitation (#2220)
Co-authored-by: thinkerou <thinkerou@gmail.com>
2020-02-06 14:50:21 +08:00
Bo-Yi Wu 0e4d8eaf07
tree: remove duplicate assignment (#2222)
copy from cfa3cb764b

Co-authored-by: thinkerou <thinkerou@gmail.com>
2020-01-28 18:35:47 +08:00
Bo-Yi Wu 64e6a7654f docs(path): improve comments (#2223)
* chore(path): improve comments

copy from 15782a78c6

* fix typo

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2020-01-28 11:38:45 +08:00
Andy Pan 07c0f05f24 Renew README to fit the modification of SetCookie method (#2217)
fix #2214
2020-01-23 07:54:08 +08:00
Bo-Yi Wu 69a202dbbd chore: upgrade go-isatty and json-iterator/go (#2215) 2020-01-22 00:24:25 +08:00
ali f94406a087 Added support for SameSite cookie flag (#1615)
* Added support for SameSite cookie flag

* fixed tests.

* Update context.go

* Update context_test.go

* Update context_test.go

Co-authored-by: thinkerou <thinkerou@gmail.com>
Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2020-01-20 15:12:44 +08:00
Andy Pan 982daeb1ec Use zero-copy approach to convert types between string and byte… (#2206)
* Use zero-copy approach to convert types between string and byte slice

* Rename argument to a eligible one

Benchmark:

BenchmarkBytesConvBytesToStrRaw-4   	21003800	        70.9 ns/op	      96 B/op	       1 allocs/op
BenchmarkBytesConvBytesToStr-4      	1000000000	         0.333 ns/op	       0 B/op	       0 allocs/op
BenchmarkBytesConvStrToBytesRaw-4   	18478059	        59.3 ns/op	      96 B/op	       1 allocs/op
BenchmarkBytesConvStrToBytes-4      	1000000000	         0.373 ns/op	       0 B/op	       0 allocs/op


Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2020-01-18 00:32:50 +08:00
guonaihong 362376322e add comment 2020-01-16 22:52:42 +08:00
Andy Pan ace6e4c2ea path: sync code with httprouter (#2212) 2020-01-16 22:40:59 +08:00
Andrey Abramov 424e9685be Update docs on Context.Done(), Context.Deadline() and Context.Err() (#2196)
Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2020-01-08 01:48:28 +08:00
Andy Pan 025950afe9 Reuse bytes when cleaning the URL paths (#2179)
* path: use stack buffer in CleanPath to avoid allocs in common case

Sync from 8222db13db

* path: sync test code from httprouter

* path: update path_test.go to the latest code

Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2020-01-07 17:37:18 +08:00
Antoine GIRARD fd8a65b252 Add build tag nomsgpack (#1852)
* add build tag nomsgpack

* Update copyright

* Update copyright
2020-01-07 11:31:10 +08:00
John Bampton b8a7b6d194 Fix spelling (#2202) 2020-01-07 09:19:49 +08:00
John Bampton 59ab588bf5 Remove broken link from README. (#2198) 2019-12-30 21:55:08 +08:00
Lin Kao-Yuan 9b3477ef9d Update validator to v10 (#2190)
Passed my manual test, output nothing different.
2019-12-20 14:01:58 +08:00
飞雪无情 cc14a770cd upgrade go-validator to v10 for README (#2189) 2019-12-19 11:21:58 +08:00
Lin Kao-Yuan 1b480ed294 Update to currently output (#2188)
Excuse me, I forgot change output in #2186
2019-12-18 21:08:58 +08:00
thinkerou d6143d8d7c tree: remove one else statement (#2177) 2019-12-18 16:58:38 +08:00
Lin Kao-Yuan aee83e040b Fix "Custom Validators" example (#2186)
* Update fixed error code from merged commit

According to [this](874dcfa6c4) merged commit.

* Fixed incorrect testing date.

Original testing date incompatible demo require, can't get expect result.
check_in date need NOT AFTER check_out date.
2019-12-18 09:44:33 +08:00
guonaihong 1e858d5bd7 modify code 2019-12-11 19:05:54 +08:00
thinkerou 168fa94516
tree: sync httprouter update (#2173) 2019-12-09 15:04:35 +08:00
thinkerou 6e16da8683
tree: sync httprouter update (#2172) 2019-12-08 19:34:05 +08:00
thinkerou c6544855d7 tree: sync httprouter update (#2171) 2019-12-08 18:35:08 +08:00
guonaihong 7e9f808e02 fix empty value error
Here is the code that can report an error
```go
package main

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"io"
	"net/http"
	"os"
	"time"
)

type header struct {
	Duration   time.Duration `header:"duration"`
	CreateTime time.Time     `header:"createTime" time_format:"unix"`
}

func needFix1() {
	g := gin.Default()
	g.GET("/", func(c *gin.Context) {
		h := header{}
		err := c.ShouldBindHeader(&h)
		if err != nil {
			c.JSON(500, fmt.Sprintf("fail:%s\n", err))
			return
		}

		c.JSON(200, h)
	})

	g.Run(":8081")
}

func needFix2() {
	g := gin.Default()
	g.GET("/", func(c *gin.Context) {
		h := header{}
		err := c.ShouldBindHeader(&h)
		if err != nil {
			c.JSON(500, fmt.Sprintf("fail:%s\n", err))
			return
		}

		c.JSON(200, h)
	})

	g.Run(":8082")
}

func sendNeedFix1() {
	// send to needFix1
	sendBadData("http://127.0.0.1:8081", "duration")
}

func sendNeedFix2() {
	// send to needFix2
	sendBadData("http://127.0.0.1:8082", "createTime")
}

func sendBadData(url, key string) {
	req, err := http.NewRequest("GET", "http://127.0.0.1:8081", nil)
	if err != nil {
		fmt.Printf("err:%s\n", err)
		return
	}

	// Only the key and no value can cause an error
	req.Header.Add(key, "")
	rsp, err := http.DefaultClient.Do(req)
	if err != nil {
		return
	}
	io.Copy(os.Stdout, rsp.Body)
	rsp.Body.Close()
}

func main() {
	go needFix1()
	go needFix2()

	time.Sleep(time.Second / 1000 * 200) // 200ms
	sendNeedFix1()
	sendNeedFix2()
}

```
2019-12-06 15:49:43 +08:00
thinkerou 7c21e04f62
fix maxParams bug (#2166) 2019-12-04 07:56:01 +08:00
Victor Castell 77b8344169 Add project to README (#2165)
Add Dkron as user of Gin in the README
2019-12-02 20:59:56 +08:00
thinkerou 3abc96e3cd
tree: sync part httprouter codes and reduce if/else (#2163) 2019-12-01 19:53:03 +08:00
Bo-Yi Wu 3957f6bb4b docs(benchmarks): for gin v1.5 (#2153) 2019-11-29 13:07:19 +08:00
thinkerou d5f12ac6d7
use http method constant (#2155)
* use http method constant

* fix typo
2019-11-29 07:50:49 +08:00
Bo-Yi Wu 352d69c71f
chore(performance): Improve performance for adding RemoveExtraS… (#2159)
* chore: Add RemoveExtraSlash flag

* fix testing

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2019-11-29 00:02:02 +08:00
Ngalim Siregar 231ff00d1f Refactor redirect request in gin.go (#1970)
* Refactor redirect request in gin.go

* Update http status code
2019-11-26 08:19:30 +08:00
thinkerou 3c8e29b53c
drop support govendor (#2148) 2019-11-25 15:42:23 +08:00
Xudong Cai e90e2ba9b3 upgrade go-validator to v10 (#2149)
* upgrade go-validator to v10

* fix fmt
2019-11-25 14:49:45 +08:00
BradyBromley 3737520f17 Changed wording for clarity in README.md (#2122) 2019-11-25 11:03:36 +08:00
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