Skip to content

Commit

Permalink
feat(proxy): enable getting the fastly compatible JSON for an origin
Browse files Browse the repository at this point in the history
  • Loading branch information
trieloff committed May 6, 2019
1 parent 527c682 commit b1df9d3
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/Origin.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ class Origin {
return this._overrideHost;
}

toJSON(opts) {
/**
* Returns a limited JSON representation that is compatible with the Fastly API
*/
toFastlyJSON() {
const json = {
hostname: this.hostname,
error_threshold: this.errorThreshold,
Expand All @@ -133,11 +136,19 @@ class Origin {
ssl_cert_hostname: this.SSLCertHostname,
max_conn: this.maxConn,
use_ssl: this.useSSL,
path: this.path,
};
if (this.overrideHost) {
json.override_host = this.overrideHost;
}
return json;
}

/**
* Returns a full, round-trippable JSON representation
*/
toJSON(opts) {
const json = this.toFastlyJSON();
json.path = this.path;
if (opts && opts.minimal) {
return utils.pruneEmptyValues(json);
}
Expand Down

0 comments on commit b1df9d3

Please sign in to comment.