github-actions[bot] on gh-pages
deploy: 2969f82e29d1b5fcddbedff… (compare)
armanbilge on custom-update-flake-branch
rossabaker on 0.23
[ci skip] Custom branch for upd… Merge pull request #6498 from h… (compare)
github-actions[bot] on gh-pages
deploy: a64f93143565a52fdb7667c… (compare)
armanbilge on git-blame-ignore-revs
rossabaker on 0.23
[ci skip] Create `.git-blame-ig… [ci skip] add another fmt commit [ci skip] fix wrong comment and 1 more (compare)
armanbilge on git-blame-ignore-revs
[ci skip] fix wrong comment (compare)
armanbilge on git-blame-ignore-revs
[ci skip] add another fmt commit (compare)
def yolo = logMe[IO]("hello")
// scala> yolo.unsafeRunSync
// hello
def well = logMe("hello")
Users/fabio/projects/playground/src/main/scala/Playground.scala:57: Specify `IO` there: `logMe[IO]("hello")`
[error] def well = logMe("hello")
def logMe[F[_]]: Magnet[F] = new Magnet[F]
class Magnet[F[_]]
trait LowPrio {
@annotation.implicitNotFound("""Specify `IO` there: `logMe[IO]("hello")`""")
trait Error
class Catch[F[_]] {
def apply(s: String, logAction: String => F[Unit] = ???)(implicit ev: Error) =
???
}
implicit def conv2[F[_]](m: Magnet[F]): Catch[F] =
new Catch[F]
}
object Magnet extends LowPrio {
implicit def conv[F[_]: Sync](m: Magnet[F]): LogMePartiallyApplied[F] =
new LogMePartiallyApplied[F]
class LogMePartiallyApplied[F[_]: Sync] {
def apply(s: String, logAction: String => F[Unit] = { s =>
Sync[F].delay(println(s))
}) =
logAction(s)
}
}
enjoy
HttpRoutes.of
return org.http4s.package$#HttpRoutes
which is type HttpRoutes[F[_]] = Http[OptionT[F, ?], F]
with Http
being type Http[F[_], G[_]] = Kleisli[F, Request[G], Response[G]]
Request[G]
and Response[G]
with the same effect - but my request is supposed to work with IO and the response should be a stream.
Try(SSLContext.getDefault()).toOption
. The question is whether to log a warning that the default failed.
aws4s
but I'm not convinced that I want to base my api client on their model, and I don't know to what extent the signing can be abstracted out
trait Client takes type parameters
def foo(client: Client[IO]) : IO[String] = ...
Hi, is there way in http4s to get the app route or authority for incoming requests? Basically we have an app which needs to generate previous/next links and we would like to know the route that it is running on.
println(request.uri.authority)
always prints None. So we are having to pass the route as a config parameter and then recreate the link like:
(appApi.baseUri / "blah").copy(query = request.uri.query)
Any other suggestions? It seems a bit odd to have to pass your own route.
@scalolli , Request.uri
probably represents Request-URI
part of the query, which is usually just the absolute path. So it makes sense the authority
is None
.
However, HTTP 1.1-compliant clients should provide this information in another way. RFC 2616:
The most common form of Request-URI is that used to identify a resource on an origin server or gateway. In this case the absolute path of the URI MUST be transmitted (see section 3.2.1, abs_path) as the Request-URI, and the network location of the URI (authority) MUST be transmitted in a Host header field.
Also, depending on your use case, you might want to take a look at the VirtualHost
middleware.
Hi I'm working with 0.21.0-SNAPSHOT and permanently getting a JSON parse error for a simple JSON parsing example. Here's my code:
it("work with json") {
val body = json"""
{
"id" : 33 ,
"url" :"/testUrl" ,
"title" :"One" ,
"completed" : false ,
"order" : "None"
}"""
val req = request[TodoTask](Method.POST, "/").withEntity(body)
...
}
And this gives me an error:
Fiber failed.
A checked error was not handled.
org.http4s.MalformedMessageBodyFailure: Malformed message body: Invalid JSON
at org.http4s.circe.CirceInstances$.$anonfun$defaultCirceParseError$1(CirceInstances.scala:179)
at cats.syntax.EitherOps$.leftMap$extension(either.scala:144)
at org.http4s.circe.CirceInstances.$anonfun$jsonDecoderByteBufferImpl$1(CirceInstances.scala:37)
at scala.util.Either.flatMap(Either.scala:341)
Any ideas ?
For sending many requests with the blaze client is it better to do something like
BlazeClientBuilder[IO](global).resource.use{ client =>
val a = client.expect(...)
val b = client.expect(...)
val c = client.expect(...)
...
}
or
val client = BlazeClientBuilder[IO](global).resource
val a = client.use(_.expect(...))
val b = client.use(_.expect(...))
val c = client.use(_.expect(...))
...