gin
gin copied to clipboard
Adds a new StringHTML Render method
This new StringHTML()
method will allow users to render HTML without
the need of an actual file on disk.
Example:
r.GET("/saludos", func(c *gin.Context) {
c.StringHTML(200, "<html><body>Hola amigo!</body></html>")
})
Signed-off-by: Salim Afiune [email protected]
Codecov Report
Merging #1043 into master will increase coverage by
<.01%
. The diff coverage is100%
.
@@ Coverage Diff @@
## master #1043 +/- ##
==========================================
+ Coverage 96.66% 96.67% +<.01%
==========================================
Files 16 16
Lines 1711 1713 +2
==========================================
+ Hits 1654 1656 +2
Misses 49 49
Partials 8 8
Impacted Files | Coverage Δ | |
---|---|---|
context.go | 96.63% <100%> (+0.01%) |
:arrow_up: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 81007d2...a6d38b2. Read the comment docs.
I added tests so that the coverage doesn't decrease. Now it should be in the same percentage or even more:
coverage: 97.0% of statements
@appleboy I'll be interested in having your feedback about this PR. 👍
@appleboy Thanks for the review! 👍 I have updated the assert's to match the right parameter order. Since I took some of the tests as example I thought it would be a good idea to correct them. Finally just added a quick snipped of documentation in the README. Cheers! 🍻
I just updated my branch to be in sync with master
😄
there was some issue with that same method two years ago here ( https://github.com/gin-gonic/gin/issues/197#issuecomment-102701461 ), the pr is ok, just need to clarify with manu why he didn't wanted that...
sorry for the delay @afiune
@javierprovecho Thank you for looking out for this change, much appreciated. I read the comment and It make sense to do that if there is not proper method to do it (natively). I just feel it is valuable to have it available and also documented since some micro-services wont be carrying HTML files and instead automatically generating it, so this would be very useful for users that are planning to do so.
I'll be waiting to hear from Manu. :v:
@javierprovecho @appleboy Hello! 👋 I was just passing by and remembered this PR, I have rebased from master and updated anything that needs to be updated!
Is this something we still want to merge?
+1 need this feature
Codecov Report
Merging #1043 (152b648) into master (7742ff5) will increase coverage by
0.13%
. The diff coverage is84.61%
.
@@ Coverage Diff @@
## master #1043 +/- ##
==========================================
+ Coverage 98.48% 98.61% +0.13%
==========================================
Files 41 40 -1
Lines 1974 2235 +261
==========================================
+ Hits 1944 2204 +260
- Misses 17 18 +1
Partials 13 13
Impacted Files | Coverage Δ | |
---|---|---|
render/text.go | 89.47% <81.81%> (-10.53%) |
:arrow_down: |
context.go | 98.45% <100.00%> (+0.94%) |
:arrow_up: |
mode.go | 90.90% <0.00%> (-9.10%) |
:arrow_down: |
fs.go | 100.00% <0.00%> (ø) |
|
auth.go | 100.00% <0.00%> (ø) |
|
path.go | 100.00% <0.00%> (ø) |
|
tree.go | 100.00% <0.00%> (ø) |
|
errors.go | 100.00% <0.00%> (ø) |
|
logger.go | 100.00% <0.00%> (ø) |
|
deprecated.go | 100.00% <0.00%> (ø) |
|
... and 33 more |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 7742ff5...b1703a2. Read the comment docs.
Hi, Is this function going to be merged anytime soon? Or shall I try to make it work?
It has been a long time, @appleboy @javierprovecho @manucorporat - I am still interested in merging this PR, wondering if anyone is available for a quick review. 👍🏽