-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve HttpError goclient fixes nodeClient sends x-aptos-client: header
- Loading branch information
1 parent
743e904
commit 326d2d9
Showing
8 changed files
with
204 additions
and
142 deletions.
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
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,46 @@ | ||
package aptos | ||
|
||
import ( | ||
"fmt" | ||
"net/url" | ||
"runtime/debug" | ||
) | ||
|
||
const APTOS_CLIENT_HEADER = "x-aptos-client" | ||
|
||
var AptosClientHeaderValue = "aptos-go-sdk/unk" | ||
|
||
func init() { | ||
vcsRevision := "unk" | ||
vcsMod := "" | ||
goArch := "" | ||
goOs := "" | ||
buildInfo, ok := debug.ReadBuildInfo() | ||
if ok { | ||
for _, setting := range buildInfo.Settings { | ||
switch setting.Key { | ||
case "vcs.revision": | ||
vcsRevision = setting.Value | ||
case "vcs.modified": | ||
vcsMod = setting.Value | ||
case "GOARCH": | ||
goArch = setting.Value | ||
case "GOOS": | ||
goOs = setting.Value | ||
default: | ||
} | ||
} | ||
} | ||
params := url.Values{} | ||
if vcsMod == "true" { | ||
params.Set("m", "t") | ||
} | ||
params.Set("go", buildInfo.GoVersion) | ||
if goArch != "" { | ||
params.Set("a", goArch) | ||
} | ||
if goOs != "" { | ||
params.Set("os", goOs) | ||
} | ||
AptosClientHeaderValue = fmt.Sprintf("aptos-go-sdk/%s;%s", vcsRevision, params.Encode()) | ||
} |
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
Oops, something went wrong.