Created
January 22, 2018 14:54
-
-
Save joshuakfarrar/d50f7744497a88c91d2687d773732915 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package me.sent1nel | |
import cats.effect.IO | |
import io.circe.{Json, Encoder} | |
import org.http4s.HttpService | |
import org.http4s.dsl.Http4sDsl | |
import org.http4s.server.blaze.BlazeBuilder | |
import org.http4s.util.StreamApp | |
import org.http4s.circe._ | |
import io.circe._, io.circe.generic.auto._, io.circe.syntax._ | |
object App extends StreamApp[IO] with Http4sDsl[IO] { | |
implicit val StatusEncoder: Encoder[StatusMessage] = | |
Encoder.forProduct2("message", "statusCode")(s => (s.message, s.statusCode)) | |
case class StatusMessage(message: String, statusCode: Int) | |
val service = HttpService[IO] { | |
case GET -> Root / "status" => | |
Ok(StatusMessage("ok", 200).asJson) | |
} | |
def stream(args: List[String], requestShutdown: IO[Unit]) = | |
BlazeBuilder[IO] | |
.bindHttp(8080, "0.0.0.0") | |
.mountService(service, "/api/v1") | |
.serve | |
} |
Author
joshuakfarrar
commented
Jan 22, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment