Skip to content
This repository has been archived by the owner on Jan 13, 2021. It is now read-only.

Commit

Permalink
Merge pull request #423 from u5surf/issue-421
Browse files Browse the repository at this point in the history
api/v2: Add hostname to systems check HTTP response headers #421
  • Loading branch information
bonedaddy authored Dec 22, 2019
2 parents 2b3ccd7 + ab4e520 commit 48f2678
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions api/v2/routes_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"errors"
"net/http"
"os"
"time"

"github.com/RTradeLtd/Temporal/eh"
Expand All @@ -19,6 +20,12 @@ import (

// SystemsCheck is a basic check of system integrity
func (api *API) SystemsCheck(c *gin.Context) {
hostname, err := os.Hostname()
if err != nil {
api.LogError(c, err, eh.HostNameNotFoundError)(http.StatusInternalServerError)
return
}
c.Writer.Header().Set("X-API-Hostname", hostname)
Respond(c, http.StatusOK, gin.H{
"version": api.version,
"response": "systems online",
Expand Down
2 changes: 2 additions & 0 deletions eh/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,6 @@ const (
PinExtendError = "failed to extend pin duration, this likely means you haven't actually uploaded this content before"
// MaxHoldTimeError is an error message when the current hold time value would breach set pin time limits
MaxHoldTimeError = "a hold time of this long would result in a longer maximum pin time of 2 years, please reduce your hold time and try again"
// HostNameNotFoundError is an error message when api server has not hostname
HostNameNotFoundError = "an api host has not hostname, please set hostname"
)

0 comments on commit 48f2678

Please sign in to comment.