-
Notifications
You must be signed in to change notification settings - Fork 769
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
Use Json compacter in the bidders/params endpoint #3395
Merged
Merged
Changes from 3 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
2355064
Use Json compacter in the bidders/params endpoint
guscarreon cd0a663
Fix aliases
guscarreon 144ec17
escape HTML
guscarreon 8cb7a3b
Create Encoder and Decoder
guscarreon d69938b
Recovered code. Extension call in auction_test.go still missing
guscarreon 5686755
CreateDecoder func
guscarreon 1be65a6
removed go.mod and go.sum entries
guscarreon a93e96b
cleaned up code a little
guscarreon 9268615
Merge branch 'master' into removeSpaceFromBidderParams
guscarreon 8b72dd2
Merge branch 'master' into removeSpaceFromBidderParams
guscarreon 6edfb64
Commented out CreateEncode
guscarreon 0ffb7ed
Tried registering the encoder
guscarreon f1eb5c3
Scott's fix
guscarreon 7747b2e
init()
guscarreon 86ee89c
TestMain(m *testing.M)
guscarreon 84f852b
jsonutils test cases
guscarreon b6b8ba5
Cleaned up code
guscarreon 6ed5813
Scott's 2nd review part 1
guscarreon 92c00e2
Merge branch 'master' into removeSpaceFromBidderParams
guscarreon 4d08de6
Scott's 2nd review part 2
guscarreon 4978277
Scott's 2nd review part 3
guscarreon 0fc3933
LoadSchema function
guscarreon 9f13d75
InitBidderParamsValidator
guscarreon dbebd64
Rolledback functions
guscarreon 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
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
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 |
---|---|---|
|
@@ -44,6 +44,7 @@ import ( | |
"github.com/julienschmidt/httprouter" | ||
_ "github.com/lib/pq" | ||
"github.com/rs/cors" | ||
"github.com/tidwall/pretty" | ||
) | ||
|
||
// NewJsonDirectoryServer is used to serve .json files from a directory as a single blob. For example, | ||
|
@@ -76,12 +77,12 @@ func newJsonDirectoryServer(schemaDirectory string, validator openrtb_ext.Bidder | |
if !isValid { | ||
glog.Fatalf("Schema exists for an unknown bidder: %s", bidder) | ||
} | ||
data[bidder] = json.RawMessage(validator.Schema(bidderName)) | ||
data[bidder] = pretty.Ugly([]byte(validator.Schema(bidderName))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of calling the compact method manually, please add it as an extension registered with |
||
} | ||
|
||
// Add in any aliases | ||
for aliasName, parentBidder := range yamlAliases { | ||
data[string(aliasName)] = json.RawMessage(validator.Schema(parentBidder)) | ||
data[string(aliasName)] = pretty.Ugly([]byte(validator.Schema(parentBidder))) | ||
} | ||
|
||
// Add in any default aliases | ||
|
@@ -93,12 +94,15 @@ func newJsonDirectoryServer(schemaDirectory string, validator openrtb_ext.Bidder | |
data[aliasName] = bidderData | ||
} | ||
|
||
response, err := json.Marshal(data) | ||
response, err := jsonutil.Marshal(data) | ||
SyntaxNode marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if err != nil { | ||
glog.Fatalf("Failed to marshal bidder param JSON-schema: %v", err) | ||
} | ||
|
||
return func(w http.ResponseWriter, _ *http.Request, _ httprouter.Params) { | ||
enc := json.NewEncoder(w) | ||
enc.SetEscapeHTML(false) | ||
|
||
w.Header().Add("Content-Type", "application/json") | ||
w.Write(response) | ||
} | ||
|
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
Oops, something went wrong.
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.
Curious, why did you choose the
pretty
package over the built-injson.Compact
?