zarthross on v0.21.0
zarthross on master
Update scala-library, scala-ref… Merge pull request #502 from sc… (compare)
zarthross on master
Update json4s-ext, json4s-jacks… Merge pull request #505 from sc… (compare)
zarthross on master
Update sbt to 1.4.9 Merge pull request #508 from sc… (compare)
zarthross on master
Update sbt-ci-release to 1.5.7 Merge pull request #511 from sc… (compare)
zarthross on master
Update http4s-blaze-server, htt… Merge pull request #513 from sc… (compare)
zarthross on master
Update swagger-ui to 3.46.0 Merge pull request #515 from sc… (compare)
pathVar
s not supported like query param
s in terms of Enums? See above. Both use a StringParser based on an Enumeratum enum, but the path param comes through odd
implicit def producerTypeStringParser[F[_]]: StringParser[F, ProducerType] =
new StringParser[F, ProducerType] {
override def parse(
s: String
)(implicit F: Monad[F]
): ResultResponse[F, ProducerType] =
try SuccessResponse(ProducerType.withName(s))
catch {
case _: NoSuchElementException =>
FailureResponse.pure[F] {
BadRequest.pure(s"Invalid ProducerType format: '$s'")
}
}
override val typeTag: Option[TypeTag[ProducerType]] = Some(
implicitly[TypeTag[ProducerType]]
)
}
This is my StringParser FWIW
val myIdsList = paramD[List[Long]]("myIds", "Some ids")
which works as expected: it parses ?myIds=1&myIds=2
to a List[Long]
. However, how can I use my own StringParser[IO, List[Long]]
instead of QueryParsers.multipleParse
? I'd like to manually parse ?myIds=1,2
to List[Long]
.
The above came up during an upgrade from v0.19.0
to v0.20.0
where I noticed that suddenly, our custom StringParser[IO, List[Long]]
wasn't picked up and instead, QueryParsers.multipleParse
was being used.
What I see is that v0.19.0
's multiParse()
is defined for Seq[_]
while v0.20.0
's multiParse()
is defined for generic B[_]
.
I also see that QueryParsers.standardCollector
and QueryParsers.multiParse
are defined in the same scope. Would it help here if standardCollector
had higher priority than multiParse()
?
multiParse
by defining the following: implicit def http4sMultipleParseOverride[A](
implicit F: Monad[IO],
p: StringParser[IO, List[A]],
cbf: Factory[A, List[A]]
): QueryParser[IO, List[A]] =
standardCollector[List[A]](F, p)
'foo
we've introduced pv"foo"
. pv stands for pathVar.logger
?
Hi @Yotamho
You cloud copy the source of RhoRoutes, and have your own version with the logger field removed. That's what I would do.
Among other options you can also create a block { }
inside your class extending RhoRoutes. And while you cannot create a 'logger' field in the class, you can create a val logger
in the block, which will shadow the logger field inherited from RhoRoutes. You would then have to put all your code using the logger inside that block. That would work as long as you don't plan having any public members in that class (you can't put public members in the block). It's a bit hacky :P
- in: "body"
name: "body"
description: "List«Long»"
required: true
schema:
type: "array"
items:
title: "Long"
$ref: "#/definitions/Long"
type: "array"
items:
type: "integer"
format: "int64"
Object
(AnyRef), which primitives are not
Ok(...)
) into the body of new RhoRoutes[IO] { ... }
then everything started working. So my next question is, how can we achieve this without requiring that everything be written in situ?
(implicit responses: ResponseGeneratorInstances[IO])
and try and use this when declaring the routes? ... E.g. "Description of an endpoint" **
POST / "pathhere" ^ jsonOf[IO,MyType] |>> {
(body: MyType) => myDef(body)(this)
}