Created
June 5, 2017 07:15
-
-
Save kissgyorgy/b9681780c693b1b7acd3d3a4fe4f2bbd to your computer and use it in GitHub Desktop.
Python vs Go HTTP Request
This file contains hidden or 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
func (b *vaultBackend) Version() string { | |
r := b.client.NewRequest("GET", "/v1/sys/health") | |
resp, err := b.client.RawRequest(r) | |
if err != nil { | |
log.Fatal(err) | |
} | |
defer resp.Body.Close() | |
var result struct { | |
Version string | |
} | |
err = resp.DecodeJSON(&result) | |
if err != nil { | |
log.Fatal(err) | |
} | |
return fmt.Sprint(b.Name, " ", result.Version) | |
} |
This file contains hidden or 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
def version(self) -> str: | |
health_data = self._client.read('/sys/health') | |
return self.name + ' ' + health_data['version'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment