2018-08-26 19:15:48 +08:00
|
|
|
//
|
|
|
|
// Copyright (c) 2018
|
|
|
|
// Mainflux
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
//
|
|
|
|
|
2017-09-23 21:52:39 +08:00
|
|
|
package mainflux
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
2018-12-09 03:53:39 +08:00
|
|
|
const version string = "0.7.0"
|
2017-09-23 21:52:39 +08:00
|
|
|
|
2018-10-14 22:44:21 +08:00
|
|
|
type VersionInfo struct {
|
2018-04-24 19:56:13 +08:00
|
|
|
Service string `json:"service"`
|
|
|
|
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)
|
|
|
|
})
|
|
|
|
}
|