Skip to content

Instantly share code, notes, and snippets.

@jtbonhomme
Created July 20, 2019 18:05
Show Gist options
  • Save jtbonhomme/77193417be130410350fa158909564b8 to your computer and use it in GitHub Desktop.
Save jtbonhomme/77193417be130410350fa158909564b8 to your computer and use it in GitHub Desktop.
Simple version endpoint
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