Browsing the doc i see:
Multiple HttpRoutes can be combined with the combineK method (or its alias <+>)
tweetService <+> helloWorldService
I wonder what it is the outcome of that ? i.e. Combing to Kleisli with CombineK ?
https://typelevel.org/cats/typeclasses/semigroupk.html
I have a hard time picture out what that does.
Can someone help comprehend this ?
PS: I see that i could just use the Router (which combine things beneath ) and not worry, but would appreciate to have pointer as to understand what is happening.
Update1
Just double check SemigroupK for Klseisli in Cats
ealed private[data] trait KleisliSemigroupK[F[_], A] extends SemigroupK[Kleisli[F, A, *]] {
implicit def F: SemigroupK[F]
override def combineK[B](x: Kleisli[F, A, B], y: Kleisli[F, A, B]): Kleisli[F, A, B] =
Kleisli(a => F.combineK(x.run(a), y.run(a)))
override def combineKEval[B](x: Kleisli[F, A, B], y: Eval[Kleisli[F, A, B]]): Eval[Kleisli[F, A, B]] =
Eval.now(Kleisli(a => F.combineKEval(x.run(a), y.map(_.run(a))).value))
}
Knowing that our routes returns OptionT[F, Response[F]] or F[Option[Response[F]]], I'm still having a hard time figuring out what is the purpose.
Updated2
After checking Cats IO for
protected class IOSemigroupK extends SemigroupK[IO] {
final override def combineK[A](a: IO[A], b: IO[A]): IO[A] =
a.handleErrorWith(_ => b)
}
I suspect it means, try every routes up to the one that succeed.
And Router would ensure that:
The services can be mounted in any order as the request will be matched against the longest base paths first.
So far feels like something of the sort.