2017-09-23 15:52:39 +02:00
|
|
|
package mainflux
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
2018-04-24 13:56:13 +02:00
|
|
|
const version string = "0.2.3"
|
2017-09-23 15:52:39 +02:00
|
|
|
|
|
|
|
type response struct {
|
2018-04-24 13:56:13 +02:00
|
|
|
Service string `json:"service"`
|
|
|
|
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-04-24 13:56:13 +02:00
|
|
|
res := response{service, version}
|
2017-09-23 15:52:39 +02:00
|
|
|
|
|
|
|
data, _ := json.Marshal(res)
|
|
|
|
|
|
|
|
rw.Write(data)
|
|
|
|
})
|
|
|
|
}
|