tobyweston / temperature-machine

Data logger for multiple DS18B20 temperature sensors on one or more machines
Apache License 2.0
67 stars 22 forks source link

Add /version endpoint #22

Closed tobyweston closed 6 years ago

tobyweston commented 6 years ago

Add a version endpoint, something like this in a version.sbt:

val latestSha = SettingKey[String]("latest-sha")

latestSha := Process("git rev-parse HEAD").lines.head.take(6)

version in ThisBuild := latestSha.value

Then bring it back in a VersionEndpoint:

import org.http4s.HttpService
import org.http4s.dsl._

object VersionEndpoint {

  private val version = Option(getClass.getPackage.getImplementationVersion).getOrElse("UNKNOWN")

  def apply = HttpService {
    case GET -> Root / "version" => Ok(version)
  }
}
tobyweston commented 6 years ago

Under 'Live Connections' you should now see the version info (or unknown version if the connection doesn't have the new /version endpoint, implying it's an older version)

screen shot 2018-01-19 at 20 51 25

The number in brackets is the Git SHA to distinguish between "snapshot" releases / people building from source.