Skip to content

Conversation

@RyanCopley
Copy link

@RyanCopley RyanCopley commented Dec 5, 2016

Hey echo maintenance! 👋

We're utilizing Echo in a project and I'm trying to clean up some of our project. I noticed that we're converting bytes.Buffer's into strings, then back to a byte array. That seems a little bit much just to move some text around so I thought it'd be nice if there was a method that directly accepts bytes.Buffers (which this package already imports, thankfully!)

Since some templating (I'm looking at you, pongo2) engines final result is a buffer, we've been casting them to strings, which is a bit unnecessary considering under the hood Echo supports this.

Let me know if you have any questions:)

@coveralls
Copy link

coveralls commented Dec 5, 2016

Coverage Status

Coverage decreased (-4.2%) to 81.462% when pulling 460b525 on GannettDigital:master-allow-html-buffers into ff8a3bd on labstack:master.

@RyanCopley RyanCopley force-pushed the master-allow-html-buffers branch from 460b525 to 9f034c2 Compare December 5, 2016 15:58
@coveralls
Copy link

coveralls commented Dec 5, 2016

Coverage Status

Coverage decreased (-4.2%) to 81.462% when pulling 9f034c2 on GannettDigital:master-allow-html-buffers into ff8a3bd on labstack:master.

@coveralls
Copy link

coveralls commented Dec 5, 2016

Coverage Status

Coverage decreased (-4.2%) to 81.462% when pulling 9e9676c on GannettDigital:master-allow-html-buffers into ff8a3bd on labstack:master.

…sting them to strings, which is a bit unnecessary considering under the hood Echo supports this.
@RyanCopley RyanCopley force-pushed the master-allow-html-buffers branch from 9e9676c to daed69f Compare December 5, 2016 16:10
@coveralls
Copy link

coveralls commented Dec 5, 2016

Coverage Status

Coverage decreased (-4.2%) to 81.462% when pulling daed69f on GannettDigital:master-allow-html-buffers into ff8a3bd on labstack:master.

…sting them to strings, which is a bit unnecessary considering under the hood Echo supports this.
@coveralls
Copy link

coveralls commented Dec 5, 2016

Coverage Status

Coverage increased (+0.05%) to 85.737% when pulling adb05c8 on GannettDigital:master-allow-html-buffers into ff8a3bd on labstack:master.

@vishr
Copy link
Member

vishr commented Dec 5, 2016

@RyanCopley You can use Context#Blob

@RyanCopley
Copy link
Author

Ah-- blob is the word I should've looked for. That wouldn't set the content-type, and there is both an XML and XMLBlob. Would it be cool for it to be the same as HTML? I would like to not include the content type all over my code if possible:) I'll change my wording to Blob for consistency

@RyanCopley RyanCopley changed the title Add method HTMLBuffer for more streamlined / less allocating renders. Add method HTMLBlob for more streamlined / less allocating renders. Dec 6, 2016
@vishr
Copy link
Member

vishr commented Dec 6, 2016

@RyanCopley You can set content type in Blob. Can you follow the sequence like JSON, JSON => JSONBlob => Blob?

@RyanCopley
Copy link
Author

Absolutely!

func (c *context) HTMLBlob(code int, b []byte) (err error) {
return c.Blob(code, MIMETextHTMLCharsetUTF8, b)
}

Copy link
Member

@vishr vishr Dec 6, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also modify HTML to use HTMLBlob like in JSON. With that you don't need your test case as it will be already covered - just for consistency.

@coveralls
Copy link

coveralls commented Dec 7, 2016

Coverage Status

Coverage decreased (-4.2%) to 81.462% when pulling 2dff901 on GannettDigital:master-allow-html-buffers into f10daac on labstack:master.

@coveralls
Copy link

coveralls commented Dec 7, 2016

Coverage Status

Coverage increased (+0.05%) to 85.737% when pulling a5526e6 on GannettDigital:master-allow-html-buffers into f10daac on labstack:master.

@coveralls
Copy link

coveralls commented Dec 7, 2016

Coverage Status

Coverage decreased (-4.2%) to 81.462% when pulling 2dff901 on GannettDigital:master-allow-html-buffers into f10daac on labstack:master.

@RyanCopley
Copy link
Author

@vishr Done :)

@vishr
Copy link
Member

vishr commented Dec 7, 2016

Closed in #765

@vishr vishr closed this Dec 7, 2016
@vishr
Copy link
Member

vishr commented Dec 7, 2016

Thanks for your contribution 👍

@coveralls
Copy link

coveralls commented Dec 7, 2016

Coverage Status

Coverage increased (+0.02%) to 85.714% when pulling 0d6e1e5 on GannettDigital:master-allow-html-buffers into f10daac on labstack:master.

@coveralls
Copy link

coveralls commented Dec 7, 2016

Coverage Status

Coverage decreased (-0.02%) to 85.668% when pulling ceac2dd on GannettDigital:master-allow-html-buffers into f10daac on labstack:master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants