Skip to content

Commit e82decf

Browse files
committed
Fix deprecations in core
1 parent 604dbf5 commit e82decf

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

core/src/main/scala/org/http4s/HttpRoute.scala renamed to core/src/main/scala/org/http4s/HttpRoutes.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,10 @@ object HttpRoutes {
5656
*/
5757
def of[F[_]](pf: PartialFunction[Request[F], F[Response[F]]])(implicit F: Sync[F]): HttpRoutes[F] =
5858
Kleisli(req => OptionT(F.delay(pf.lift(req).sequence).flatten))
59+
60+
/** An empty set of routes. Always responds with `pOptionT.none`.
61+
*
62+
* @tparam F the base effect of the [[HttpRoutes]]
63+
*/
64+
def empty[F[_]: Applicative]: HttpRoutes[F] = liftF(OptionT.none)
5965
}

core/src/main/scala/org/http4s/HttpService.scala

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package org.http4s
33
import cats._
44
import cats.data._
55

6+
@deprecated("Replaced by HttpRoutes", "0.19")
67
object HttpService extends Serializable {
78

89
/**
@@ -14,14 +15,17 @@ object HttpService extends Serializable {
1415
def lift[F[_]: Functor](f: Request[F] => F[Response[F]]): HttpService[F] =
1516
Kleisli(f.andThen(OptionT.liftF(_)))
1617

17-
/** Lifts a partial function to an `HttpService`.
18-
* Responds with `OptionT.none` for any request where `pf` is not defined.
18+
/** Lifts a partial function to [[HttpRoutes]]. Responds with
19+
* `OptionT.none` for any request where `pf` is not defined.
20+
*
21+
* Unlike `HttpRoutes.of`, does not suspend the application of `pf`.
1922
*/
23+
@deprecated("Replaced by `HttpRoutes.of`", "0.19")
2024
def apply[F[_]](pf: PartialFunction[Request[F], F[Response[F]]])(
21-
implicit F: Applicative[F]): HttpService[F] =
25+
implicit F: Applicative[F]): HttpRoutes[F] =
2226
Kleisli(req => pf.andThen(OptionT.liftF(_)).applyOrElse(req, Function.const(OptionT.none)))
2327

24-
def empty[F[_]: Applicative]: HttpService[F] =
25-
Kleisli.liftF(OptionT.none)
26-
28+
@deprecated("Replaced by `HttpRoutes.empty`", "0.19")
29+
def empty[F[_]: Applicative]: HttpRoutes[F] =
30+
HttpRoutes.empty
2731
}

0 commit comments

Comments
 (0)