diff --git a/web.go b/web.go index 97b31ff17..65a10f392 100644 --- a/web.go +++ b/web.go @@ -15,6 +15,7 @@ import ( "github.com/containous/traefik/middlewares" "github.com/containous/traefik/safe" "github.com/containous/traefik/types" + "github.com/containous/traefik/version" "github.com/elazarl/go-bindata-assetfs" "github.com/thoas/stats" "github.com/unrolled/render" @@ -60,6 +61,7 @@ func (provider *WebProvider) Provide(configurationChan chan<- types.ConfigMessag systemRouter.Methods("GET").Path("/ping").HandlerFunc(provider.getPingHandler) // API routes systemRouter.Methods("GET").Path("/api").HandlerFunc(provider.getConfigHandler) + systemRouter.Methods("GET").Path("/api/version").HandlerFunc(provider.getVersionHandler) systemRouter.Methods("GET").Path("/api/providers").HandlerFunc(provider.getConfigHandler) systemRouter.Methods("GET").Path("/api/providers/{provider}").HandlerFunc(provider.getProviderHandler) systemRouter.Methods("PUT").Path("/api/providers/{provider}").HandlerFunc(func(response http.ResponseWriter, request *http.Request) { @@ -144,6 +146,17 @@ func (provider *WebProvider) getConfigHandler(response http.ResponseWriter, requ templatesRenderer.JSON(response, http.StatusOK, currentConfigurations) } +func (provider *WebProvider) getVersionHandler(response http.ResponseWriter, request *http.Request) { + v := struct { + Version string + Codename string + }{ + Version: version.Version, + Codename: version.Codename, + } + templatesRenderer.JSON(response, http.StatusOK, v) +} + func (provider *WebProvider) getProviderHandler(response http.ResponseWriter, request *http.Request) { vars := mux.Vars(request) providerID := vars["provider"] diff --git a/webui/src/app/core/version.resource.js b/webui/src/app/core/version.resource.js new file mode 100644 index 000000000..5ec80d56d --- /dev/null +++ b/webui/src/app/core/version.resource.js @@ -0,0 +1,14 @@ +'use strict'; +var angular = require('angular'); + +var traefikCoreVersion = 'traefik.core.version'; +module.exports = traefikCoreVersion; + +angular + .module(traefikCoreVersion, ['ngResource']) + .factory('Version', Version); + + /** @ngInject */ + function Version($resource) { + return $resource('../api/version'); + } diff --git a/webui/src/app/version/version.controller.js b/webui/src/app/version/version.controller.js new file mode 100644 index 000000000..373f28b06 --- /dev/null +++ b/webui/src/app/version/version.controller.js @@ -0,0 +1,10 @@ +'use strict'; + +/** @ngInject */ +function VersionController($scope, $interval, $log, Version) { + Version.get(function (version) { + $scope.version = version; + }); +} + +module.exports = VersionController; diff --git a/webui/src/app/version/version.module.js b/webui/src/app/version/version.module.js new file mode 100644 index 000000000..991ed2474 --- /dev/null +++ b/webui/src/app/version/version.module.js @@ -0,0 +1,11 @@ +'use strict'; +var angular = require('angular'); +var traefikCoreVersion = require('../core/version.resource'); +var VersionController = require('./version.controller'); + +var traefikVersion = 'traefik.version'; +module.exports = traefikVersion; + +angular + .module(traefikVersion, [traefikCoreVersion]) + .controller('VersionController', VersionController); diff --git a/webui/src/index.html b/webui/src/index.html index 468431563..bec9ce4d5 100644 --- a/webui/src/index.html +++ b/webui/src/index.html @@ -27,6 +27,11 @@