Commit Graph

119 Commits

Author SHA1 Message Date
grapeVine
e2b4cf6e2d interface implement type check (#1459)
interface implement type check
2018-08-06 23:08:01 +08:00
Rex Lee(李俊)
85221af84c add json ASCII string render (#1358)
add a json render that rendering json as ASCII string
2018-07-03 17:17:08 +08:00
Jean-Christophe Lebreton
bf7803815b Serve easily dynamic files with DataFromReader context method (#1304)
* Add DataFromReader context method

* Replace fmt by strconv.FormatInt

* Add pull request link to README
2018-05-12 11:00:42 +08:00
senhtry
8c24018290 Add Jsonp Support to Context (#1333) 2018-04-26 11:52:19 +08:00
田欧
dfe37ea6f1 unify assert.Equal usage (#1327)
* unify assert.Equal usage

* fix typo
2018-04-20 10:27:44 +08:00
田欧
783c7ee9c1 Add some test cases and run test cases on binding/render dir (#1168)
* Travis run test cases on binding and render dir and add some test cases for binding and render
2018-01-26 11:46:11 +08:00
Weilin Shi
a816f9e9db Remove redundant if err != nil check (#1202)
* Remove redundant if err != nil check

* Return e.EncodeToken instead of create a new variable
2017-12-21 11:00:17 +08:00
田欧
3b300929e8 Empty string check (#1101) 2017-09-29 00:22:35 +08:00
田欧
a8fa424ae5 update comment (#1057) 2017-08-16 11:55:50 +08:00
Bo-Yi Wu
ce670a6497 refactor(json): make jsonite optional with build tags (#1026)
* refactor(json): Restore gin support for app engine

Create new folder to support multiple json package.
restore gin support for app engine (disable jsonite through tags)

use jsoniter

$ go build -tags=jsoniter .

use default json

$ go build .

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

* rename json file.

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

* docs(json): add build tags document.

* fix(docs): markdown format.

* fix(json): missing space.
2017-07-18 23:01:29 +02:00
Eason Lin
8436a9d829 fix(render): remove repeated static check. (#998) 2017-07-10 01:45:19 -05:00
Bo-Yi Wu
e23842ecab
fix json sort the map keys
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2017-07-08 18:19:09 +08:00
Bo-Yi Wu
12508320c2
feat: change json lib to jsoniter
A high-performance 100% compatible drop-in replacement of "encoding/json"

https://github.com/json-iterator/go

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2017-07-08 16:51:36 +08:00
Eason Lin
75ed286c60 feat: add SecureJSON func to prevent json hijacking 2017-07-08 01:21:30 +08:00
田欧
34e972e155 Separate type define (#983) 2017-07-06 07:59:27 -05:00
Thomas Boerger
e38c36ee0d
Made funMaps for the templates configurable and hot-reloadable 2017-06-30 21:22:40 +02:00
sope
35f5df63e6 add custom Delims support (#860)
* Revert "Merge pull request #753 from gin-gonic/bug"

This reverts commit 556287ff08, reversing
changes made to 32cab500ec.

* Revert "Merge pull request #744 from aviddiviner/logger-fix"

This reverts commit c3bfd69303, reversing
changes made to 9177f01c28.

* add custom Delims support

* add some test for Delims

* remove the empty line for import native package

* remove unuseful comments
2017-05-29 03:03:49 -05:00
Harindu Perera
5be2123c1a Added support for MessagePack binding and rendering (#808)
Added deps to vendor.json and fixed rendering bug
2017-02-23 22:08:37 +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
Bo-Yi Wu
787bff85e5 fix testing.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-12-11 10:14:23 +08:00
chriswhelix
97d310b55c Honor normal gin write contract for context.JSON()
Gin normally silently swallows errors writing to the client; however in WriteJSON (and thus context.JSON), the ResponseWriter was being passed directly into the JSON encoder, which will return an error if there's an error writing to the stream. For instance, context.JSON would panic with errors like "write tcp XXX-> YYY: write: connection reset by peer" if the client disconnected before the response was complete. This change makes JSON.Render() treat write errors the same as IndentedJSON, Data, and other renderers.
2016-12-11 10:14:23 +08:00
Javier Provecho Fernandez
9e930b9bdd lint code 2016-04-15 01:16:46 +02:00
Javier Provecho
007bd5124a closes #514, code from bobbo@b4f0b50 2016-04-14 23:47:49 +02:00
Manu Mtz.-Almeida
97cd894279 c.Redirect() allows 201 status code 2016-01-28 00:34:05 +01:00
Manu Mtz-Almeida
352868ef90 Add support for custom HTML and XML content-type 2015-06-13 04:43:23 +02:00
Manu Mtz-Almeida
a7c957af7d Adds supports for custom JSON Content-type 2015-06-13 04:29:10 +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
a21cc8dd3d Updates HTML render 2015-06-01 00:15:16 +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
a2105ce34c Fast path for setting headers.
- No heap allocation
- No indirection
- CanonicalMIMEHeaderKey() is not called
2015-05-23 16:39:25 +02:00
Manu Mtz-Almeida
ffaf49da0e Adds MIT license 2015-05-22 19:21:23 +02:00
Manu Mtz-Almeida
306da81aaf Cosmetic changes in render 2015-05-22 04:44:29 +02:00
Manu Mtz-Almeida
880dd7f3cf Fixes bug in HTMLDebug 2015-05-21 20:27:25 +02:00
Manu Mtz-Almeida
66251d1741 Simplifies c.File() 2015-05-21 15:49:10 +02:00
Manu Mtz-Almeida
947b53d4a2 New Render API 2015-05-18 15:45:24 +02:00
Manu Mtz-Almeida
51a64abe86 Setting "Cache-Control" to "no-cache" in SSE 2015-05-14 02:08:47 +02:00
Manu Mtz-Almeida
662a35d209 Using sse.ContentType instead of hardcoded one 2015-05-13 23:24:56 +02:00
Manu Mtz-Almeida
b0af2b4c11 Using github.com/manucorporat/sse 2015-05-13 20:27:45 +02:00
Manu Mtz-Almeida
57f6940dba Fixes JSON rendering 2015-05-13 02:34:46 +02:00
Manu Mtz-Almeida
470b7e1010 Adds support for Server-Sent Events 2015-05-12 18:33:41 +02:00
Manu Mtz-Almeida
a9dad532ae Performance improvement in renders 2015-05-11 01:02:17 +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
f414648384 - More unit tests
- Improves HTML debug render
- InputHolder removed
- More debug logs
2015-05-05 15:06:38 +02:00
Manu Mtz-Almeida
0a192fb0fa Tons of unit tests 2015-04-09 12:15:02 +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
d33079d0ec Performance improvement when writing formatted strings 2015-04-07 19:54:17 +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
1213878e9a Using data first argument 2015-03-31 18:04:52 +02:00
Manu Mtz-Almeida
abcc6d9dec Adds indented JSON render 2015-03-31 18:02:38 +02:00
Manu Mtz-Almeida
4a37b0808b Refactors Context initialization 2015-03-31 17:39:30 +02:00
Manu Mtz-Almeida
df3ed787e1 Fixes debug HTML rendering:
- Stateless algorithm
2015-03-31 17:36:13 +02:00
Manu Mtz-Almeida
8f31fbc502 Refactors render.go 2015-03-23 04:42:05 +01:00
Javier Provecho Fernandez
cf8150ed2b Add HTML no template string output support #197 2015-03-08 17:50:58 +01:00
Ignacio Galindo
b69dde8e68 Specify utf-8 as content type charset on renderers 2015-01-29 20:14:13 -06:00
Ludwig Valda Vasquez
e5a7bcd6df fix typo in PR for #119 2014-09-17 07:47:29 +04:00
Ludwig Valda Vasquez
97ae4a6b65 Fix for #119. gin.LoadHTML* incorrectly works in debug mode. 2014-09-17 07:33:13 +04:00
Manu Mtz-Almeida
8e5397bfa0 Adds in-code license 2014-08-29 19:49:50 +02:00
Manu Mtz-Almeida
46225ea53a Fixes html debug mode 2014-08-21 01:04:35 +02:00
Manu Mtz-Almeida
378610b3b2 HTML template debug mode.
- theHTML templates are reloaded each time
2014-08-20 18:14:10 +02:00
Manu Mtz-Almeida
ceec1b6443 Merge branch 'redirect' of https://github.com/alexandernyquist/gin into develop 2014-08-18 17:19:32 +02:00
Manu Mtz-Almeida
dcafad3ced Deferring WriteHeader. Part 1 2014-08-18 05:24:48 +02:00
Alexander Nyquist
e350ae7c7e Removed redundancy when redirecting 2014-07-29 00:53:56 +02:00
Alexander Nyquist
593de4e913 Added support for redirects 2014-07-29 00:48:02 +02:00
mopemoepe
2947981b61 Fix Corrupted plainRender 2014-07-18 08:56:59 +09:00
Manu Mtz-Almeida
a1ff907768 Fixed Content-Type for json render. Thank you @mdigger 2014-07-16 02:49:22 +02:00
Manu Mtz-Almeida
5ea7a92267 Adds flexible render system 2014-07-15 17:41:56 +02:00