org.http4s.rho
The AuthedContext provides a convenient way to define a RhoService which works with http4s authentication middleware.
case class User(name: String, id: UUID) object Auth { val authUser: Service[Request, User] = Kleisli({ _ => Task.now(User("Test User", UUID.randomUUID())) }) val authenticated = AuthMiddleware(authUser) } object MyAuth extends AuthedContext[User] object MyService extends RhoService { import MyAuth._ GET +? param("foo", "bar") |>> { (req: Request, foo: String) => val user = getAuth(req) if (user.name == "Test User") { Ok(s"just root with parameter 'foo=$foo'") } else { BadRequest("This should not have happened.") } } } val service = Auth.authenticated(MyAuth.toService(MyService.toService(SwaggerSupport())))
authInfo type for this service.
Turn the HttpService into an AuthedService
AuthedService
HttpService to convert
An AuthedService which can be mounted by http4s servers.
The AuthedContext provides a convenient way to define a RhoService which works with http4s authentication middleware.
authInfo type for this service.