Commit Graph

249 Commits

Author SHA1 Message Date
田欧
a8fa424ae5 update comment (#1057) 2017-08-16 11:55:50 +08:00
Eason Lin
df37e74fa1 doc(context): more clearer bind doc when input is not valid (#1049) 2017-08-01 12:49:28 +08:00
Eason Lin
7fafb3f4a1 doc(context): add status func comment. (#1042) 2017-07-28 08:50:58 +08:00
Eason Lin
c19aa0598b feat(context): add BindQuery func (#1029)
* feat(context): add BindQuery func, only parse/bind the query string params.

* docs(readme): add BindQuery section.

* docs(readme): fix import.

* docs(readme): separate import
2017-07-19 09:50:05 +02:00
田欧
7180f2ba62 not use tmp var (#1032) 2017-07-17 22:39:39 -05:00
Eason Lin
93b3a0d7ec feat(context): add SaveUploadedFile func. (#1022)
* feat(context): add SaveUploadedFile func.

* feat(context): update multiple upload examples.

* style(example): fix gofmt

* fix(example): add missing return
2017-07-15 22:42:08 -05:00
田欧
aa6d2d29f8 refactor(doc): use space not tab (#1006) 2017-07-11 10:28:08 -05:00
Eason Lin
75ed286c60 feat: add SecureJSON func to prevent json hijacking 2017-07-08 01:21:30 +08:00
田欧
e0fd6238d3 use comma ok and use single line (#984) 2017-07-06 09:49:54 -05:00
田欧
b985857899 update func comment (#981) 2017-07-05 20:28:16 -05:00
Javier Provecho Fernandez
42a34cdc35 docs(context): document keys, errors, and accepted, close #488 2017-07-05 16:55:59 +02:00
Javier Provecho Fernandez
d875f07409 Merge branch 'master' into develop 2017-07-02 14:23:55 +02:00
Javier Provecho Fernandez
68aa2c38da fix(context): switch deprecated bindwith for mustbindwith 2017-06-28 00:46:35 +02:00
Javier Provecho Fernandez
1a9cba2cc7 Merge pull request #855 from gin-gonic/feat/662
feat(context): add idiomatic binding functions for clear err managment
2017-06-28 00:16:34 +02:00
Javier Provecho Fernandez
9a79e3f144 fix(import): switch sse import from gopkg to github 2017-06-27 23:17:02 +02:00
Bo-Yi Wu
1e1e4fc867 Add Makefile to check the following thing (#947)
* Add Makefile to check the following thing.

* vet check
* fmt check
* embedmd check
* misspell check

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* remove unused variable.

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2017-06-12 21:50:42 -05:00
collinmsn
3f95933c3d Add method to return main handler (#930)
Fix #928 Method to get main handler is desired
2017-06-02 03:00:55 -05:00
Javier Provecho Fernandez
5eea51b6c9 feat(context): add cast helpers to c.Keys (#856)
* feat(context): add cast helpers to c.Keys

* Add tests for cast helpers to c.Keys
2017-06-01 20:00:04 -05:00
Ammar Bandukwala
781cbd19f0
panic if err is nil on c.Error
A panic here provides a more informative stack trace than the panic which would otherwise occur while errors are being collected.
2017-05-09 22:30:56 -05:00
Rahul Datta Roy
d4a53101c3 Fix minor type in context.go (#900)
* Fix minor type in context.go

* More spelling fixes in context.go
2017-05-04 09:22:48 +08:00
Bo-Yi Wu
41316b9ca9 feat: add GetRawData func. (#857)
* feat: add GetRawData func.

* update return style

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2017-03-31 08:45:56 +08:00
Javier Provecho
73e5fcd855 feat(context): add idiomatic binding functions for clear err managment 2017-03-29 14:32:12 +00:00
Bo-Yi Wu
ad2dacedd6 feat: Support get value from request header. (#839) 2017-03-24 20:43:23 +08:00
pjgg
6ce1e86a27 chore(errorHandler):new abortWithStatus method with Json body (#800) 2017-02-14 09:11:01 +08:00
mbesancon
2d8477fc42 Fixed typos in Context (#797)
Simple english typos in the Copy() method
2017-02-01 22:47:50 +08:00
Javier Provecho Fernandez
963acc4b0c Fix #198 (#781)
* Add new function to Render interface for writing content type only

* Add support for the new function in Render interface for writing content-type only

* Fix unhandled merge conflict in context_test.go

* Update vendor.json
2017-01-09 16:24:48 +01:00
tsirolnik
c115074d77 Use X-Forwarded-For before X-Real-Ip
Nginx uses X-Real-Ip with its IP instead of the client's IP. Therefore, we should use X-Forwarded-For *before* X-Real-Ip
2017-01-03 23:43:05 +08:00
David Irvine
ebe3580daf Add convenience method to check if websockets required (#779)
* Add convenience method to check if websockets required

* Add tests

* Fix up tests for develop branch
2017-01-02 16:05:30 +08:00
Bo-Yi Wu
5cc3d5955f Support upload single or multiple files.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-12-24 12:25:01 +08:00
Javier Provecho Fernandez
2cab17ba50 Merge pull request #701 from maxatome/patch-1
Context.Get() does not need to test whether Keys is nil or not
2016-12-06 20:39:01 +01:00
Bo-Yi Wu
764e138e32 Merge pull request #755 from gin-gonic/755-app-engine-client-ip
Fix #723
2016-12-06 08:14:11 -06:00
Javier Provecho Fernandez
7e58c80a7c Fix #723 2016-12-06 14:28:01 +01:00
Javier Provecho Fernandez
273e43a27a Merge pull request #724 from chiffa-org/redundant_context_import
Move golang.org/x/net/context.Context interface implementation check to tests
2016-12-05 10:55:06 +01:00
Bo-Yi Wu
6f474cb42d Merge pull request #570 from andreynering/array
Implement QueryArray and PostFormArray methods
2016-12-03 08:12:19 +08:00
Vyacheslav Dubinin
ceb250ba20 Move golang.org/x/net/context.Context interface implementation check to tests 2016-10-19 17:13:38 +03:00
Maxime Soulé
bf8da4a08a Context.Get() does not need to test whether Keys is nil or not 2016-09-09 11:37:22 +02:00
Javier Provecho Fernandez
9e930b9bdd lint code 2016-04-15 01:16:46 +02:00
Javier Provecho Fernandez
4df51ad4f8 Merge pull request #587 from roylou/develop
Write header immediately in AbortWithStatus(), close #585
2016-04-15 00:36:29 +02:00
Javier Provecho
007bd5124a closes #514, code from bobbo@b4f0b50 2016-04-14 23:47:49 +02:00
Roy Lou
4c4444b160 Write header immediately in AbortWithStatus()
Otherwise, caller needs to invoke WriteHeaderNow himself after
AbortWithStatus(), which is error-prone.

Also modified ErrorLoggerT() such that it always writes log to response
body. Otherwise calling AbortWithStatus() will fail to write body because
c.Writer.Written() is set true by WriteHeaderNow().
2016-04-15 00:02:29 +08:00
Kamron Batman
70c104e16c [Cleanup] Typo in context.go
Fixes typo from 'If Parses' to 'It parses'
2016-04-01 16:29:28 -07:00
Andrey Nering
f3ff8f827c Refactor GetQuery and GetPostForm 2016-03-29 21:54:21 -03:00
Andrey Nering
9366e33ffc Implement QueryArray and PostArray methods 2016-03-29 21:48:50 -03:00
Michael Puncel
7171b967a3 s/currect/current 2016-03-07 21:56:46 -08:00
Michael Puncel
13565e1bf5 fix typo in godoc for func (*Context) HandlerName 2016-03-07 20:54:10 -08:00
Manu Mtz.-Almeida
44978ff780 Improves Context documentation
Query(), GetQuery(), PostForm(), GetPostForm()...
2016-01-29 02:42:19 +01:00
Manu Mtz.-Almeida
afc499f306 Adds GetQuery() and GetPostForm() APIs 2016-01-29 02:07:44 +01:00
Manu Mtz.-Almeida
d64a1fb91c Cosmetic changes 2016-01-28 00:35:09 +01:00
Manu Mtz.-Almeida
61fae4997d Improves documentation 2016-01-26 22:40:29 +01:00
Manu Mtz.-Almeida
e9531e5c76 Merge branch 'master' into develop 2016-01-26 20:08:28 +01:00
Manu Mtz.-Almeida
e6d563577d Merge branch 'master' of github.com:gin-gonic/gin 2016-01-26 20:08:14 +01:00
Manu Mtz.-Almeida
4c639a5049 Cosmetic changes:
- Deprecating GetCookie()
2016-01-26 18:36:37 +01:00
Manu Mtz.-Almeida
2fc2a3e782 Rendering error throws a panic() 2016-01-26 18:35:04 +01:00
Manu Mtz.-Almeida
9abb909731 Merge branch 'master' into develop 2016-01-26 15:55:44 +01:00
Manu Mtz.-Almeida
7b4e9a81a5 Cosmetic changes 2016-01-26 15:55:30 +01:00
Manu Mtz.-Almeida
d0cd8b9fd9 Adds Status() method to Context 2016-01-26 14:55:45 +01:00
Brian Wigginton
353fa14750 additional clarification 2015-10-27 12:26:05 -05:00
Brian Wigginton
1541a141ee update docs for context.Abort
The docs were a little unclear as to how to use Abort, and how it will affect the current handler.
2015-10-27 12:22:18 -05:00
Javier Provecho Fernandez
4892650ef8 Merge branch 'se77en-master' into develop 2015-10-02 12:38:32 +02:00
Javier Provecho Fernandez
8e37eb8498 Fix tests for GetCookie() and SetCookie() 2015-10-02 12:37:51 +02:00
Javier Provecho Fernandez
45b72951af Merge branch 'master' of https://github.com/se77en/gin into se77en-master 2015-10-02 11:25:25 +02:00
Javier Provecho Fernandez
558d6b582f Merge branch 'fix' of https://github.com/donnpebe/gin into donnpebe-fix 2015-10-02 09:54:06 +02:00
Damon Zhao
e1d27558b3 add parameters for set cookie 2015-09-08 15:37:20 +08:00
Damon Zhao
f5b1fb44bb Add SetCookie and GetCookie method for Context 2015-08-27 16:04:50 +08:00
Manu Mtz-Almeida
e8bc8f48e9 Merge branch 'master' into develop
Conflicts:
	README.md
	gin.go
	routergroup.go
2015-08-16 18:38:13 +02:00
Manu Mtz-Almeida
5f2f8d9cb4 Better documentation 2015-07-05 03:26:30 +02:00
Javier Provecho Fernandez
7c0c427b2d Fix #252 typo (middlewares -> middleware) 2015-07-03 20:12:01 +02:00
Manu Mtz-Almeida
8f3047814e Comments + IRoutes + IRouter + unexported AbortIndex 2015-07-02 20:24:54 +02:00
Manu Mtz-Almeida
16b08c41c9 Merge branch 'fix_is_aborted_method' of https://github.com/adwinsky/gin 2015-07-02 18:42:41 +02:00
Manu Mtz-Almeida
a20984c2bc Adds comments 2015-07-02 18:42:33 +02:00
Adam Dratwinski
74f5051cb5 Fix IsAborted() method 2015-07-02 13:37:11 +02:00
Donn Pebe
c1719f7e20 Use only the ip part of request RemoteAddr 2015-07-02 01:48:21 +07:00
Manu Mtz-Almeida
95c08d5f84 Adds HandlerName() 2015-06-25 19:44:52 +02:00
Manu Mtz-Almeida
58b5e15870 Adds ForwardedByClientIP option 2015-06-07 13:51:13 +02:00
Manu Mtz-Almeida
70325deb98 c.ClientIP() performance improvement
benchmark                 old ns/op     new ns/op     delta
BenchmarkManyHandlers     4956          4463          -9.95%

benchmark                 old allocs     new allocs     delta
BenchmarkManyHandlers     16             13             -18.75%

benchmark                 old bytes     new bytes     delta
BenchmarkManyHandlers     256           216           -15.62%
2015-06-04 13:15:22 +02:00
Manu Mtz-Almeida
822b995687 c.JSON performance improvement
benchmark                 old ns/op     new ns/op     delta
BenchmarkOneRouteJSON     1143          1053          -7.87%

benchmark                 old allocs     new allocs     delta
BenchmarkOneRouteJSON     4              3              -25.00%

benchmark                 old bytes     new bytes     delta
BenchmarkOneRouteJSON     72            56            -22.22%
2015-06-04 13:08:29 +02:00
Manu Mtz-Almeida
56683d33b1 c.String() performance improvements
```
benchmark                   old ns/op     new ns/op     delta
BenchmarkOneRouteString     448           310           -30.80%

benchmark                   old allocs     new allocs     delta
BenchmarkOneRouteString     1              0              -100.00%

benchmark                   old bytes     new bytes     delta
BenchmarkOneRouteString     48            0             -100.00%
```
2015-06-04 12:53:42 +02:00
Manu Mtz-Almeida
1f56e50083 Using Render() instead of Write() 2015-06-04 05:25:21 +02:00
Manu Mtz-Almeida
1228b03914 Fixing some unit tests 2015-05-31 18:35:28 +02:00
Manu Mtz-Almeida
e60087f223 Fixed documentation error 2015-05-31 17:31:26 +02:00
Manu Mtz-Almeida
835f66fdc9 404 not found performance improvements
benchmark            old ns/op     new ns/op     delta
Benchmark404         737           249           -66.21%
Benchmark404Many     2330          454           -80.52%

benchmark            old allocs     new allocs     delta
Benchmark404         3              0              -100.00%
Benchmark404Many     10             0              -100.00%

benchmark            old bytes     new bytes     delta
Benchmark404         115           68            -40.87%
Benchmark404Many     235           57            -75.74%
2015-05-30 14:45:13 +02:00
Manu Mtz-Almeida
48633f7001 Better documentation 2015-05-29 21:03:41 +02:00
Manu Mtz-Almeida
e899d8a99e Code cleanup + documentation 2015-05-28 03:22:34 +02:00
Manu Mtz-Almeida
af8e099dfd Fixes multipart integration 2015-05-26 16:31:05 +02:00
Manu Mtz-Almeida
500d745123 PostForm() handles multipart post 2015-05-26 16:16:57 +02:00
Manu Mtz-Almeida
195ea88a28 Cosmetic changes 2015-05-26 12:35:05 +02:00
Manu Mtz-Almeida
d209329891 Updates documentation 2015-05-26 12:13:51 +02:00
Manu Mtz-Almeida
865ea804c9 Renames new API for query/postform and params. 2015-05-26 12:08:33 +02:00
Manu Mtz-Almeida
0a9030f9d7 ClientIP() must trim the white spaces 2015-05-24 15:35:08 +02:00
Manu Mtz-Almeida
9163ee543d Merge branch 'develop' 2015-05-22 17:00:07 +02:00
Manu Mtz-Almeida
37b6f6c179 Fixing new errors API 2015-05-22 16:39:15 +02:00
Manu Mtz-Almeida
b7205a6ec2 Fixes new errors API. 2015-05-22 03:43:39 +02:00
Manu Mtz-Almeida
e94247f9ad New errors API!! 2015-05-22 03:25:21 +02:00
Manu Mtz-Almeida
5f76ba2022 Context.Engine renamed to Context.engine 2015-05-22 02:24:13 +02:00
Manu Mtz-Almeida
66251d1741 Simplifies c.File() 2015-05-21 15:49:10 +02:00
Manu Mtz-Almeida
f9952b0545 Experimenting with golang.org/x/net/context 2015-05-18 21:26:29 +02:00
Manu Mtz-Almeida
c467186d20 Renames Negotiate.HTMLPath to Negotiate.HTMLName 2015-05-18 20:52:26 +02:00
Manu Mtz-Almeida
6313545df7 Drops c.Return() API 2015-05-18 20:51:52 +02:00
Manu Mtz-Almeida
21b5154fd7 New rendering pipeline 2015-05-18 16:09:15 +02:00
Manu Mtz-Almeida
947b53d4a2 New Render API 2015-05-18 15:45:24 +02:00
Manu Mtz-Almeida
470b7e1010 Adds support for Server-Sent Events 2015-05-12 18:33:41 +02:00
Manu Mtz-Almeida
99694bb716 Fixes errors 2015-05-12 15:22:13 +02:00
Manu Mtz-Almeida
421793bfba Experiments: HTTP streaming render 2015-05-12 15:17:46 +02:00
Manu Mtz-Almeida
3df5dfdb7f Faster IndentedJSON + unit tests 2015-05-11 01:04:08 +02:00
Manu Mtz-Almeida
d6771dc4a5 Cosmetic changes 2015-05-09 03:35:31 +02:00
Manu Mtz-Almeida
2d8f0a4801 Performance improvements when rendering
- Fast path for JSON, XML and plain text rendering
2015-05-07 12:44:52 +02:00
Manu Mtz-Almeida
eb3e9293ed Renames []HandleFunc to HandlersChain 2015-05-07 11:30:01 +02:00
Manu Mtz-Almeida
79131ac84d Tail call optimization 2015-05-07 11:28:25 +02:00
Manu Mtz-Almeida
495e6e116e Adds IndentedJSON 2015-05-06 22:31:01 +02:00
Manu Mtz-Almeida
f414648384 - More unit tests
- Improves HTML debug render
- InputHolder removed
- More debug logs
2015-05-05 15:06:38 +02:00
Sridhar Ratnakumar
ffd35c365e Fix typo/grammar in function comment 2015-04-25 21:27:04 -07:00
Manu Mtz-Almeida
0a192fb0fa Tons of unit tests 2015-04-09 12:15:02 +02:00
Manu Mtz-Almeida
4d315f474b More unit tests 2015-04-08 14:24:49 +02:00
Manu Mtz-Almeida
8b26264574 Merge branch 'develop' into performance
Conflicts:
	context.go
	context_test.go
	gin_test.go
	recovery_test.go
	utils.go
2015-04-08 13:37:25 +02:00
Manu Mtz-Almeida
ac0ad2fed8 Improves unit tests 2015-04-08 02:58:35 +02:00
Manu Mtz-Almeida
1532be7c10 Context Accepted is an exported variable 2015-04-07 23:28:36 +02:00
Manu Mtz-Almeida
a4eadceb45 Merge branch 'develop' into performance
Conflicts:
	binding/form_mapping.go
	context_test.go
2015-04-07 19:59:43 +02:00
Manu Mtz-Almeida
3abeba82fc Context redirect uses the built-in redirect facility 2015-04-07 12:27:02 +02:00
Manu Mtz-Almeida
1f6304ca25 Cleaning up performance branch 2015-04-07 12:22:38 +02:00
Manu Mtz-Almeida
2915fa0ffe Zero allocation router, first commit 2015-03-31 21:39:06 +02:00
Manu Mtz-Almeida
d4413b6e91 Refactors binding module 2015-03-31 17:51:10 +02:00
Manu Mtz-Almeida
18880f9215 ForwardedFor() is deprecated 2015-03-31 17:44:45 +02:00
Manu Mtz-Almeida
4a37b0808b Refactors Context initialization 2015-03-31 17:39:30 +02:00
Manu Mtz-Almeida
59d949d350 Moves errorMsg to errors.go 2015-03-26 14:10:46 +01:00
Manu Mtz-Almeida
9d59fc51bc math package is missing 2015-03-26 14:07:01 +01:00
Manu Mtz-Almeida
31323f694b AbortIndex is missing 2015-03-26 04:27:34 +01:00
Manu Mtz-Almeida
1e417c7a50 Refactors Context allocation 2015-03-25 19:33:17 +01:00
Manu Mtz-Almeida
48fec0650d Cosmetic changes 2015-03-23 06:03:12 +01:00
Manu Mtz-Almeida
3e3ced70d4 Using log.Panic instead 2015-03-23 05:50:10 +01:00
Manu Mtz-Almeida
3285007fbb Refactores context.go 2015-03-23 04:39:53 +01:00
Matt Williams
e8fc0c74b4 gin/context.go: Minor change in Abort comment 2015-03-17 18:51:03 +00:00
Javier Provecho Fernandez
cf8150ed2b Add HTML no template string output support #197 2015-03-08 17:50:58 +01:00
Aleksandr Didenko
0fb7bed1c0 Added support multipart/form-data #109 2015-03-08 15:43:37 +01:00
techjanitor
a900e7888c Update context.go
Add localhost to proxies
2015-02-07 22:44:53 -06:00
Remco
e4f6e053d0 Fixed issue allowing to spoof ClientIP()
The X-Forwared-For can be used to spoof the real client ip. The middleware
introduced in this patch (which should only be used when having servers
in front of this servers) will filter all defined proxies (or local ip
addresses by default) and replace the RemoteAddr with the real client
ip.
2014-12-21 13:42:48 +01:00
Manu Mtz-Almeida
aa7b00a083 General refactoring. Part 2. 2014-10-09 01:40:42 +02:00
Manu Mtz-Almeida
07a3961941 General refactoring 2014-10-08 21:37:26 +02:00
Manu Mtz-Almeida
012c935a46 Better errors in Context.Negotiation 2014-08-31 18:41:11 +02:00
Manu Mtz-Almeida
275bdc194e Fixes Content.Negotiate API 2014-08-31 18:28:18 +02:00
Manu Mtz-Almeida
ffea7e88a2 Working on content type negotiation API 2014-08-30 22:22:57 +02:00
Manu Mtz-Almeida
8e5397bfa0 Adds in-code license 2014-08-29 19:49:50 +02:00
Alexander Nyquist
64fb835e6f Only accepting 3xx status codes when redirecting. Swapped location and code arguments for Redirect signature 2014-08-02 17:06:09 +02:00
Alexander Nyquist
e350ae7c7e Removed redundancy when redirecting 2014-07-29 00:53:56 +02:00
Alexander Nyquist
2c4460d7cc Fixed status code when redirecting 2014-07-29 00:51:34 +02:00
Alexander Nyquist
593de4e913 Added support for redirects 2014-07-29 00:48:02 +02:00
Manu Mtz-Almeida
c7fdc2e03a Errors in context are removed 2014-07-18 00:29:20 +02:00
Manu Mtz-Almeida
48f4914165 Performance improvement
- Reduces number of allocations per context
- Improves CPU cache usage
2014-07-18 00:10:28 +02:00
Manu Mtz-Almeida
8ed55606c3 Adds context.File(path) 2014-07-17 02:01:42 +02:00
Manu Mtz-Almeida
dc43372610 Splitting source code in different files 2014-07-16 20:14:03 +02:00