github-actions[bot] on gh-pages
deploy: 2d89d1150cbc55dd40232a8… (compare)
danicheg on series
danicheg on 0.23
Update sbt-scoverage to 2.0.2 i… Merge pull request #6601 from h… (compare)
github-actions[bot] on gh-pages
deploy: 60532fc82da39d5f0f62063… (compare)
armanbilge on series
armanbilge on 0.23
Update sbt-native-packager to 1… Merge pull request #6599 from h… (compare)
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(...))
...
_.putHeaders
does what you want though, assoming you are ok with the eta expansion.