question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using predefined status responses without extending Http4sDsl

See original GitHub issue

Is there an easy way to use use e.g. NotFound() without extending Http4sDsl?

I would imagine something like import import org.http4s.magic and then magic.NotFound[IO]() or magic.NotFound[F]()

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
valenterrycommented, Jul 21, 2019

org.http4s.dsl.tagless, maybe?

Let me make a draft PR and see how it feels 😃

1reaction
ChristopherDavenportcommented, Jul 19, 2019

Not saying we should do it, but the import trick specifically does work. I now follow, yes. You can have it scoped for the function, but you can’t import the values without explicitly doing so. We could however have a good space for a different dsl with the verbose syntax.

That being said, I prefer just building responses myself.

@ import $ivy.`org.http4s::http4s-dsl:0.21.0-M2`
import $ivy.$

@ import cats.effect._, cats.implicits._, org.http4s._, org.http4s.dsl._
import cats.effect._, cats.implicits._, org.http4s._, org.http4s.dsl._

@ def Ok2[F[_]: Sync, A: EntityEncoder[F, ?]](a: A): F[Response[F]] = {
     val dsl = new Http4sDsl[F]{}; import dsl._
     Ok(a)
  }
defined function Ok2
Read more comments on GitHub >

github_iconTop Results From Across the Web

The http4s DSL
Responding with a body. Simple bodies. Most status codes take an argument as a body. In http4s, Request[F] and Response[F] ...
Read more >
http4s/http4s - Gitter
I'm on 0.16.16a, and I'm seeing this error while using the blaze client: java.util.concurrent.TimeoutException: Client response header ...
Read more >
Unleashing the Power of HTTP Apis: The Http4s Library
The routes defined using the http4s DSL are composable. ... For example, the Ok() function creates a response with a 200 HTTP status:....
Read more >
17 HTTP API with http4s - Get Programming with Scala
You'll discover how to implement an HTTP server that replies to a GET /ping request with a response with status code 200 –...
Read more >
Error handling in Http4s with classy optics - Typelevel
I'll explain later in this post why it extends Exception . ... according http response and our code compiles without any warning whatsoever....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found