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