Skip to content

Instantly share code, notes, and snippets.

Last active Oct 30, 2016
What would you like to do?
package net.gutefrage
import com.twitter.finagle._
import com.twitter.finagle.http.service.HttpResponseClassifier
import com.twitter.server.TwitterServer
import com.twitter.util.Await
import io.finch._
import io.finch.circe._
import net.gutefrage.temperature.thrift._
* Serves the mean temperature at `/weather/mean`
object WeatherApi extends TwitterServer {
def main(): Unit = {
val client = ThriftMux.client.newIface[TemperatureService.FutureIface](
"zk!!/service/temperature", "weather-api-client")
/** json model */
case class Mean(mean: Double)
// mean temperature endpoint
val api: Endpoint[Mean] = get("weather" / "mean") {
client.mean().map(mean => Ok(Mean(mean)))
// start and announce the server
val server = Http.server
// 5xx response should be classified as server errors
name = "zk!!0",
addr = s":8080",
service = api.toService
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment