Serve API version list, test with an integration test.

This commit is contained in:
Daniel Smith
2014-10-28 17:20:40 -07:00
parent 1da5c444e8
commit dca7363459
6 changed files with 47 additions and 0 deletions

View File

@@ -135,6 +135,13 @@ func handleVersion(w http.ResponseWriter, req *http.Request) {
writeRawJSON(http.StatusOK, version.Get(), w)
}
// APIVersionHandler returns a handler which will list the provided versions as available.
func APIVersionHandler(versions ...string) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
writeRawJSON(http.StatusOK, version.APIVersions{Versions: versions}, w)
})
}
// writeJSON renders an object as JSON to the response.
func writeJSON(statusCode int, codec runtime.Codec, object runtime.Object, w http.ResponseWriter) {
output, err := codec.Encode(object)