harness-drone/handler/web/version.go
2019-02-19 15:56:41 -08:00

26 lines
681 B
Go

// Copyright 2019 Drone.IO Inc. All rights reserved.
// Use of this source code is governed by the Drone Non-Commercial License
// that can be found in the LICENSE file.
package web
import (
"net/http"
"github.com/drone/drone/version"
)
// HandleVersion creates an http.HandlerFunc that returns the
// version number and build details.
func HandleVersion(w http.ResponseWriter, r *http.Request) {
v := struct {
Source string `json:"source,omitempty"`
Version string `json:"version,omitempty"`
Commit string `json:"commit,omitempty"`
}{
Source: version.GitRepository,
Commit: version.GitCommit,
Version: version.Version.String(),
}
writeJSON(w, &v, 200)
}