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-09-05 05:32:04 +08:00
|
|
|
const version string = "0.5.1"
|
2017-09-23 21:52:39 +08:00
|
|
|
|
|
|
|
type response 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-04-24 19:56:13 +08:00
|
|
|
res := response{service, version}
|
2017-09-23 21:52:39 +08:00
|
|
|
|
|
|
|
data, _ := json.Marshal(res)
|
|
|
|
|
|
|
|
rw.Write(data)
|
|
|
|
})
|
|
|
|
}
|