I have the following code snippet:
final class UserRoutes[F[_]: Defer: JsonDecoder: MonadThrow](
auth: Auth[F]
) extends Http4sDsl[F] {
private[routes] val prefixPath = "/auth"
private val httpRoutes: HttpRoutes[F] =
HttpRoutes.of[F] {
case req @ POST -> Root / "users" =>
req
.decodeR[CreateUser] { user =>
auth
.newUser(
user.username.toDomain,
user.password.toDomain
)
.flatMap(Created(_))
.recoverWith {
case UserNameInUse(u) =>
Conflict(u.value)
}
}
}
val routes: HttpRoutes[F] = Router(
prefixPath -> httpRoutes
)
}
that I do not understand the meaning of the expression private[routes] val prefixPath = "/auth"
. Could anyone please clarify the meaning of the expression?
It means that the prefixPath
member is only accessible on UserRoutes
from the routes
package.