-
Notifications
You must be signed in to change notification settings - Fork 8.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Protobuf format response and unit test #1479
Merged
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
5682f53
Add support for Protobuf format response
salamer 42dd325
add TestRenderProtoBuf
salamer 11e1ba3
add protobuf render test
salamer 1aa0e18
chore: add return or remove else for reduce indent (#1470)
thinkerou 7d89b71
improve utils code coverage (#1473)
thinkerou df04038
improve render code coverage (#1474)
thinkerou a712509
unify test data (#1417)
thinkerou 9ce5f61
docs: remove double negative in README.md (#1480)
awulkan 85d33ff
chore: use http.Status* instead of hard code (#1482)
thinkerou 06d50f1
add issue and pull request template explain (#1483)
thinkerou a190c8b
docs: add changelog for v1.3.0, update authors and version const (#1478)
javierprovecho 95fdb35
Fix typo in readme (#1490)
houjunchen 3cce9fb
chore: upgrade dependency library version (#1491)
thinkerou 4e28f1e
Add BindXML AND ShouldBindXML #1484 (#1485)
syssam 64ecab2
Set default time format in form binding (#1487)
lokhman b62f951
readme: fix users link (#1493)
easonlin404 6af1a17
Fix typo in README [ci skip] (#1492)
crispgm 65a97e1
Update readme about the version of gin (#1494)
chainhelen b6cb77e
add full protobuf rendering test
salamer 86fe335
fixed typo
salamer 8ba804b
fixed missed code
salamer 75aa0c0
filled test
salamer 5be19bd
update annotation of protobuf
salamer e51d726
add some protobuf rendering examples in README, add some tests and up…
salamer 47a973a
update the README code annotations, make it more clear
salamer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
Add support for Protobuf format response
- Loading branch information
commit 5682f53f386312e5b1413996ec2b8fc5aa6e5d34
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright 2014 Manu Martinez-Almeida. All rights reserved. | ||
// Use of this source code is governed by a MIT style | ||
// license that can be found in the LICENSE file. | ||
|
||
package render | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/golang/protobuf/proto" | ||
) | ||
|
||
type ProtoBuf struct { | ||
Data proto.Message | ||
} | ||
|
||
var protobufContentType = []string{"application/x-protobuf"} | ||
|
||
func (r ProtoBuf) Render(w http.ResponseWriter) error { | ||
r.WriteContentType(w) | ||
|
||
bytes, err := proto.Marshal(r.Data) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
w.Write(bytes) | ||
return nil | ||
} | ||
|
||
func (r ProtoBuf) WriteContentType(w http.ResponseWriter) { | ||
writeContentType(w, protobufContentType) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change to