Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.

Commit

Permalink
! routing: move UserPassAuthenticator.cached to `CachedUserPassAuth…
Browse files Browse the repository at this point in the history
…enticator.apply`, fixes #352

Because `UserPassAuthenticator.cached` relies on a spray-caching Cache even code not using this method
(but simply other `UserPassAuthenticator` methods like `apply` or `fromConfig`) must have spray-caching
on the classpath in order to avoid a `bad symbolic reference` compiler error.
This patch moves the `cached` method into a dedicated object thereby freeing up `UserPassAuthenticator`
from the dependency on the spray-caching module.
  • Loading branch information
sirthias committed Jul 2, 2013
1 parent ea3e689 commit 1326046
Showing 1 changed file with 4 additions and 2 deletions.
Expand Up @@ -47,14 +47,16 @@ object UserPassAuthenticator {
}
}
}
}

object CachedUserPassAuthenticator {
/**
* Creates a wrapper around an UserPassAuthenticator providing authentication lookup caching using the given cache.
* Note that you need to manually add a dependency to the spray-caching module in order to be able to use this method.
*/
def cached[T](inner: UserPassAuthenticator[T], cache: Cache[Option[T]] = LruCache[Option[T]]())(implicit ec: ExecutionContext): UserPassAuthenticator[T] =
def apply[T](inner: UserPassAuthenticator[T], cache: Cache[Option[T]] = LruCache[Option[T]]())(implicit ec: ExecutionContext): UserPassAuthenticator[T] =
userPassOption
cache(userPassOption) {
inner(userPassOption)
}
}
}

0 comments on commit 1326046

Please sign in to comment.