Skip to content

Instantly share code, notes, and snippets.

@aeons
Created June 12, 2019 09:22
Show Gist options
  • Save aeons/5077622a25f158c66b29e086b04009b2 to your computer and use it in GitHub Desktop.
Save aeons/5077622a25f158c66b29e086b04009b2 to your computer and use it in GitHub Desktop.
Save the input file with ISO-8859-1 encoding and then run `curl -X POST -d @input --header "Content-Type: application/xml; charset=ISO-8859-1" http://localhost:3000`
package test
import cats.effect.{ExitCode, IO, IOApp}
import cats.implicits._
import org.http4s.HttpRoutes
import org.http4s.dsl.Http4sDsl
import org.http4s.implicits._
import org.http4s.server.blaze.BlazeServerBuilder
object Main extends IOApp with Http4sDsl[IO] {
def run(args: List[String]): IO[ExitCode] =
BlazeServerBuilder[IO]
.bindHttp(3000, "localhost")
.withHttpApp(testService.orNotFound)
.resource
.use(_ => IO.never)
.as(ExitCode.Success)
val testService = HttpRoutes.of[IO] {
case req @ POST -> Root =>
req.as[String].flatMap(Ok(_))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment