Skip to content
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

Change Logserver to use c.JSON method ; remove variable for endpoint name #1582

Merged
merged 40 commits into from
May 25, 2023
Merged
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
0219ce8
add explicit dmsgpty whitelist
0pcom May 13, 2023
30d4055
add WIP env detection to skywire-cli config gen
0pcom May 14, 2023
2136e61
stashing changes
0pcom May 15, 2023
28cf999
add whitelist for survey collecton over dmsghttp
0pcom May 15, 2023
7f5f6a7
Merge branch 'dmsghttp-wl' into config-envs
0pcom May 15, 2023
13d67d6
small fixes and formatting optimizations
0pcom May 15, 2023
cc0f8b0
make format
0pcom May 15, 2023
598a398
add nolint
0pcom May 15, 2023
f4a5b85
remove unused variable, use print-style function instead of printf-style
0pcom May 15, 2023
664b652
merge develop
0pcom May 19, 2023
1c6cd55
update config gen with more flags ; support survey whitelist, route &…
0pcom May 21, 2023
68adf7b
update vendor
0pcom May 21, 2023
22a5d5c
update vendor
0pcom May 21, 2023
8eb076e
update vendor dependencies and go.mod
0pcom May 22, 2023
9728b5b
add error checks, comments
0pcom May 22, 2023
bb13cd4
fix merge conflicts
0pcom May 22, 2023
26ee1f8
update vendor
0pcom May 22, 2023
7662a3d
fix vendor deps & update go.mod
0pcom May 22, 2023
e19f5de
make format & fix test error
0pcom May 22, 2023
4361174
remove viper from config gen
0pcom May 23, 2023
9a3e04e
make format
0pcom May 23, 2023
289b167
prepare to revert some changes
0pcom May 23, 2023
93a7f7e
prepare to revert some changes
0pcom May 23, 2023
f9df75d
fix panic on visor startup
0pcom May 23, 2023
e94d07b
fix ci errors
0pcom May 23, 2023
3287ca4
fix ci errors
0pcom May 23, 2023
15fc1c6
fix golangci-lint errors for version 1.52.1
0pcom May 23, 2023
7a7cdab
update golangci-lint version used by github-actions CI in test workfl…
0pcom May 23, 2023
5174f48
fix CI darwin error
0pcom May 23, 2023
49ce0d9
update visor init and visorconfig values with SurveyName
0pcom May 24, 2023
041a06a
merge develop
0pcom May 24, 2023
a5e5dc4
use config gen from develop
0pcom May 24, 2023
9656094
fix comment
0pcom May 24, 2023
0612c0d
fix spelling on help menu
0pcom May 25, 2023
8a18313
changes per review ; add reward.txt file authenticated endpoint for f…
0pcom May 25, 2023
7322064
make format check
0pcom May 25, 2023
d951d3a
Merge branch 'develop' into logserver
0pcom May 25, 2023
4450f8a
use c.JSON response method for dmsghttp server survey endpoint
0pcom May 25, 2023
4b1cfaa
authRoute.GET("/node-info"...
0pcom May 25, 2023
9b26241
fix ci errors
0pcom May 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 5 additions & 13 deletions pkg/visor/logserver/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,13 @@ func New(log *logging.Logger, tpLogPath, localPath, customPath string, whitelist
authRoute.Use(whitelistAuth(whitelistedPKs))
}
// note that the survey FILE only exists / is generated if the reward address is set
authRoute.StaticFile("/"+visorconfig.NodeInfo, filepath.Join(localPath, visorconfig.NodeInfo))
authRoute.StaticFile("/"+visorconfig.NodeInfo, filepath.Join(localPath, visorconfig.NodeInfo)) // "/node-info.json"

// serve the file with the reward address - only exists if the reward address is set
authRoute.StaticFile("/"+visorconfig.RewardFile, filepath.Join(localPath, visorconfig.RewardFile))
authRoute.StaticFile("/"+visorconfig.RewardFile, filepath.Join(localPath, visorconfig.RewardFile)) // "/reward.txt"

//Derive the surveyName from visorconfig.NodeInfo by dropping the ".json" suffix
surveyName := strings.TrimSuffix(string(visorconfig.NodeInfo), ".json")
// This survey endpoint generates the survey as a response
authRoute.GET("/"+surveyName, func(c *gin.Context) {
authRoute.GET("/node-info", func(c *gin.Context) {
var rewardAddress string
var cAddr coincipher.Address
//check for reward address
Expand All @@ -87,14 +86,7 @@ func New(log *logging.Logger, tpLogPath, localPath, customPath string, whitelist
if err != nil {
log.WithError(err).Error("Could not marshal system survey to json.")
}

c.Header("Content-Type", "application/json")
c.Writer.WriteHeader(http.StatusOK)

_, err = c.Writer.Write([]byte(s))
if err != nil {
httputil.GetLogger(c.Request).WithError(err).Errorf("failed to write json response")
}
c.JSON(http.StatusOK, s)
})

r.GET("/health", func(c *gin.Context) {
Expand Down