Commit Graph

1508 Commits

Author SHA1 Message Date
ZYunH 78a8b5c9d5 Fix typo () 2019-05-23 11:37:34 +08:00
itcloudy 0cbf290302 use encode replace json marshal increase json encoder speed () 2019-05-22 07:48:50 +08:00
Kirill Motkov b1d607a899 Some code improvements ()
* strings.ToLower comparison changed to strings.EqualFold.
* Rewrite switch statement with only one case as if.
2019-05-21 23:08:52 +08:00
guonaihong 8ee9d959a0 Now you can parse the inline lowercase start structure ()
* Now you can parse the inline lowercase start structure

package main

import (
	"encoding/json"
	"fmt"
	"github.com/gin-gonic/gin"
)

type appkey struct {
	Appkey string `json:"appkey" form:"appkey"`
}

type Query struct {
	Page int `json:"page" form:"page"`
	Size int `json:"size" form:"size"`
	appkey
}

func main() {

	router := gin.Default()
	router.POST("/login", func(c *gin.Context) {

		var q2 Query

		if c.ShouldBindQuery(&q2) == nil {
			c.JSON(200, &q2)
		}
	})
	router.Run(":8088")
}

http client:

old:
curl -X POST "127.0.0.1:8088/login?appkey=china&page=1&size=10"
{"page":1,"size":10,"appkey":""}

now:
curl -X POST "127.0.0.1:8088/login?appkey=china&page=1&size=10"
{"page":1,"size":10,"appkey":"china"}

* Modify judgment conditions
2019-05-13 10:17:31 +08:00
田欧 965d74cebb
add dev version ()
* add dev version

* Update version.go

* Update version.go
2019-05-12 18:47:27 +08:00
Uwe Dauernheim 04eecb1283 Use DefaultWriter and DefaultErrorWriter for debug messages ()
Aligns behaviour according to documentation.
2019-05-10 14:03:25 +08:00
田欧 5a7e3095b2 Update README.md about go version () 2019-05-08 11:10:34 +08:00
田欧 b75d67cd51
update vendor: ugorji/go ()
* update vendor: ugorji/go

* fix
2019-05-07 19:43:05 +08:00
Dan Markham b6425689dc Clean the Request Path early ()
This will reduce the number of times we have todo a redirect.
and allow multiple slashes in path to be routed!
fixes 
2019-05-07 19:32:35 +08:00
Dmitry Kutakov 66d2c30c54 binding: move tests of mapping to separate test file ()
* move tests of mapping to separate test file

make 100% coverage of form_mapping.go from form_mapping_test.go file

* fix tests for go 1.6

go 1.6 doesn't support `t.Run(...)` subtests
2019-05-07 19:06:55 +08:00
Dan Markham 094f9a9105 v1.4.0 + (remove go1.6/go1,7 support) ()
* remove go1.6 support

* remove build tag

* remove todo

* remove go1.6 support: https://github.com/gin-gonic/gin/pull/1383/commits

* update readme

* remove go1.7 support

* fix embedmd error

* test

* revert it

* revert it

* remove context_17

* add pusher test

* v1.4.0 rc1
2019-05-07 18:32:32 +08:00
DeathKing 202f8fc58a Fix a typo syscanll.SIGTERM -> syscall.SIGTERM () 2019-04-24 20:21:41 +08:00
John Bampton 11407e73ad Fix spelling. () 2019-04-22 23:11:57 +08:00
Abhishek Chanda f9de6049cb Remove contents of the Authorization header while dumping requests ()
This PR replaces the contents of that header with a *. This prevents
credential leak in logs.
2019-04-18 10:45:37 +08:00
Eason Lin ffcbe77b1e chore(readme): rollback readme ()
  
Keep the documentation in readme until full available on the new website.
2019-04-06 21:48:33 +08:00
Dmitry Kutakov 2e915f4e50 refactor(form_mapping.go): mapping multipart request ()
* refactor(form_mapping.go): mapping multipart request

* add checkers for a types to match with the setter interface

* form_mapping.go: rename method name on setter interface, add comments

* fix style of comments
2019-04-02 09:01:34 +08:00
Dan Markham ce20f107f5 Truncate Latency precision in long running request ()
fixes 
2019-03-28 14:14:00 +08:00
田欧 1d462bbe37
chore: update ginS () 2019-03-21 15:12:06 +08:00
田欧 0c1f3c4e81 chore: fix invalid link () 2019-03-20 12:07:34 +08:00
Sai b40d4c175c IsTerm flag should not be affected by DisableConsoleColor method. ()
* IsTerm flag should not be affected by DisableConsoleColor method.

* change public property to private
2019-03-18 11:12:30 +08:00
Boyi Wu c16bfa7949 update for supporting file binding ()
update for supporting multipart form and file binding 

example:
```
type PhoptUploadForm struct {
	imgData    *multipart.FileHeader `form:"img_data" binding:"required"`
	ProjectID   string `form:"project_id" binding:"required"`
	Description string `form:"description binding:"required"`
}
```


ref: https://github.com/gin-gonic/gin/issues/1263
2019-03-18 10:16:34 +08:00
sekky0905 bcf36ade9f Remove sudo setting from travis.yml () 2019-03-16 16:09:10 +08:00
David Zhang 05b5c3ba74 Doc: fix gin example notice syntax () 2019-03-15 15:39:34 +08:00
Sai 242a2622c8 Fix Japanese text hiragana -> kanji () 2019-03-14 16:26:51 +08:00
Dmitry Kutakov 483f828bce add support arrays on mapping ()
* add support arrays on mapping

* not allow default value on array mapping
2019-03-14 13:34:56 +08:00
田欧 cab0749b4f
chore: update readme ()
* update readme

* add multi-language version doc link

* add multi-language version doc link

* update readme

* update

* update readme

* update readme

* update readme
2019-03-14 13:23:35 +08:00
田欧 e5261480fd
chore(readme.md): fix invalid link () 2019-03-12 14:01:12 +08:00
Sai 4a23c4f7b9 fix which is caused by calling middleware twice. ()
Fix: https://github.com/gin-gonic/gin/issues/1804

`allNoRoute` contains middlewares such as `gin.Logger`, `gin.Recovery`, so on.  The correct code is to use `noRoute`.

cc: @MetalBreaker
2019-03-11 10:52:47 +08:00
田欧 70a0aba3e4
travisci: use go module when go11+ () 2019-03-08 23:18:52 +08:00
Sai f7079a861e Delete dupilicated test () 2019-03-08 19:44:39 +08:00
Adam Zielinski 3dc247893e make context.Keys available as LogFormatterParams ()
* make context available as LogFormatterParams

* pass context Keys to LogFormatterParams

* update logger test to check for Key param
2019-03-07 09:47:31 +08:00
Riverside 057f63b1bb spell check ()
* spell check

* variable path collides with imported package name

* spell check
2019-03-05 09:41:37 +08:00
田欧 a5dda62cdc
chore: use internal/json () 2019-03-05 06:46:18 +08:00
Dmitry Kutakov 805b2d4904 add support time.Duration on mapping () 2019-03-04 11:37:46 +08:00
Kumar McMillan f8f1459619 Fix URL to starter template in the docs () 2019-03-04 08:06:46 +08:00
田欧 df366c7840
chore: update go mod package () 2019-03-04 07:28:03 +08:00
Dmitry Kutakov 0d50ce8597 refactor(form_mapping.go): mapping ptr, struct and map ()
* refactor(form_mapping.go): mapping ptr, struct and map

* fix  correct work with ptr - not create value if field is not set
* avoid allocations on strings.Split() - change to strings.Index()
* fix  tag value "-" is mean ignoring field
* struct fields mapped like json.Unmarshal
* map fields mapped like json.Unmarshal

* fix after @thinkerou review
2019-03-03 14:39:43 +08:00
Daniel Krom 893c6cae07 Added stream flag indicates if client disconnected in middle of streaming () 2019-03-02 23:07:37 +08:00
Bo-Yi Wu 3b84a430d0 Drone switch from gin to go-chi in 1.0 version. () 2019-03-02 20:19:42 +08:00
田欧 8c8002d744 chore: add examples repo link to README () 2019-03-02 19:21:10 +08:00
Dang Nguyen 688eb1281c update examples link in README () 2019-03-02 16:04:21 +08:00
田欧 0feaf8cbd8
Split examples to alone repo ()
* split examples to alone repo

* vendor

* fix package error

* add examples/README.md
2019-03-01 23:42:41 +08:00
Emmanuel Goh ccb9e90295 Extend context.File to allow for the content-dispositon attachments via a new method context.Attachment ()
* Add FileAttachment method to context to allow instant downloads with filenames

* Add relevant tests for FileAttachment method
2019-03-01 10:17:47 +08:00
Equim 2dd3193006 Support negotiation wildcards, fix ()
* support negotiation wildcards, fix 

* fix typo
2019-03-01 10:03:14 +08:00
田欧 9bacadd3ea remove docs dir ()
the post doc move https://gin-gonic.com/blog/
2019-03-01 07:11:02 +08:00
Dmitry Kutakov 7dfa6c936a fix : correct error comparison on tests () 2019-02-28 22:43:27 +08:00
Tudor Roman ccb105dbcb add prefix from X-Forwarded-Prefix in redirectTrailingSlash ()
* add prefix from X-Forwarded-Prefix in redirectTrailingSlash

* added test

* fix path import
2019-02-27 19:56:29 +08:00
Raphael Gavache e207a3ce65 Fix context.Copy() race condition ()
* Fix context.Copy race condition

* Update githubapi_test.go

* fix code format
2019-02-26 15:10:16 +08:00
Luis GG 62749f0db4 Add context.HandlerNames() ()
* Add context.HandlerNames()

This change adds a HandlerNames method that will return all registered handles in the context, in descending order

This is useful for debugging and troubleshooting purposes, especially in large apps

* Tests

Add tests for HandlerNames

* Fix HandlerNames test

* Simplify test
2019-02-26 12:15:40 +08:00
田欧 d6adc8d0cc chore: add go1.12 support ()
* chore: add go1.12 support

* Update .travis.yml
2019-02-26 10:45:44 +08:00