Skip to content

Instantly share code, notes, and snippets.

@tomatophobia
Created May 26, 2021 15:35
Show Gist options
  • Select an option

  • Save tomatophobia/981c3d434f9e793b57465966644dbdca to your computer and use it in GitHub Desktop.

Select an option

Save tomatophobia/981c3d434f9e793b57465966644dbdca to your computer and use it in GitHub Desktop.
type HttpApp = Request => Future[Response]
val app: HttpApp = {
case Request(POST, Uri("/translate"), text) =>
Translator.future(text).map(Response(OK, _))
case _ =>
Future.successful(Response(NotFound))
}
// Unit test
val req = Request(POST, Uri("/translate"), "one")
// req: Request = Request(POST,Uri(/translate),one)
asyncAssert("uno", app(req).map(_.body))
// ✔ uno
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment