2019-10-07 22:14:47 +08:00
|
|
|
// Copyright (c) Mainflux
|
2018-08-26 19:15:48 +08:00
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2017-09-23 21:52:39 +08:00
|
|
|
package mainflux
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
2020-05-29 22:05:55 +08:00
|
|
|
const version string = "0.11.0"
|
2017-09-23 21:52:39 +08:00
|
|
|
|
2019-07-25 08:22:28 +08:00
|
|
|
// VersionInfo contains version endpoint response.
|
2018-10-14 22:44:21 +08:00
|
|
|
type VersionInfo struct {
|
2019-07-25 08:22:28 +08:00
|
|
|
// Service contains service name.
|
2018-04-24 19:56:13 +08:00
|
|
|
Service string `json:"service"`
|
2019-07-25 08:22:28 +08:00
|
|
|
|
|
|
|
// Version contains service current version value.
|
2018-04-24 19:56:13 +08:00
|
|
|
Version string `json:"version"`
|
2017-09-23 21:52:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Version exposes an HTTP handler for retrieving service version.
|
2018-04-24 19:39:15 +08:00
|
|
|
func Version(service string) http.HandlerFunc {
|
2017-09-23 21:52:39 +08:00
|
|
|
return http.HandlerFunc(func(rw http.ResponseWriter, _ *http.Request) {
|
2018-10-14 22:44:21 +08:00
|
|
|
res := VersionInfo{service, version}
|
2017-09-23 21:52:39 +08:00
|
|
|
|
|
|
|
data, _ := json.Marshal(res)
|
|
|
|
|
|
|
|
rw.Write(data)
|
|
|
|
})
|
|
|
|
}
|