|
@@ -1,6 +1,3 @@
|
|
|
-import java.time.format.DateTimeFormatter
|
|
|
-import java.time.{Instant, ZoneOffset}
|
|
|
-
|
|
|
import com.twitter.io.Buf
|
|
|
import com.twitter.finagle.http.Response
|
|
|
import com.twitter.finagle.Http
|
|
@@ -14,15 +11,12 @@ import io.finch.circe._
|
|
|
|
|
|
object Main extends App {
|
|
|
|
|
|
- val timeFormatter: DateTimeFormatter =
|
|
|
- DateTimeFormatter.RFC_1123_DATE_TIME.withZone(ZoneOffset.UTC)
|
|
|
-
|
|
|
val helloWorld: Buf = Buf.Utf8("Hello, World!")
|
|
|
|
|
|
val json: Endpoint[Json] = get("json") {
|
|
|
Ok(Json.obj("message" -> Json.fromString("Hello, World!")))
|
|
|
.withHeader("Server" -> "Finch")
|
|
|
- .withHeader("Date" -> timeFormatter.format(Instant.now()))
|
|
|
+ .withHeader("Date" -> currentTime())
|
|
|
}
|
|
|
|
|
|
// Downgrade a text/plain endpoint to `Endpoint[Response]` as per
|
|
@@ -32,9 +26,9 @@ object Main extends App {
|
|
|
rep.content = helloWorld
|
|
|
rep.contentType = "text/plain"
|
|
|
rep.headerMap.set("Server", "Finch")
|
|
|
- rep.headerMap.set("Date", timeFormatter.format(Instant.now()))
|
|
|
+ rep.headerMap.set("Date", currentTime())
|
|
|
|
|
|
- Ok(rep)
|
|
|
+ rep
|
|
|
}
|
|
|
|
|
|
Await.ready(Http.server
|