Created
July 20, 2019 18:05
-
-
Save jtbonhomme/77193417be130410350fa158909564b8 to your computer and use it in GitHub Desktop.
Simple version endpoint
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
package endpoint | |
import ( | |
"encoding/json" | |
"net/http" | |
) | |
var ( | |
// GITCOMMIT will be overwritten automatically by the build system | |
GITCOMMIT = "HEAD" | |
// BUILDTIME will be overwritten automatically by the build system | |
BUILDTIME = "unknown" | |
// CIJOB will be overwritten automatically by the build system | |
CIJOB = "unknown" | |
) | |
type Version struct { | |
JobID string `json:"jobId"` | |
Commit string `json:"commit"` | |
Buildtime string `json:"buildtime"` | |
} | |
func (e *httpendpoint) GetVersion(w http.ResponseWriter, r *http.Request) { | |
w.Header().Set("Content-Type", "application/json") | |
var version = Version{ | |
JobID: CIJOB, | |
Buildtime: BUILDTIME, | |
Commit: GITCOMMIT, | |
} | |
json.NewEncoder(w).Encode(version) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment