S.addAround(new LoanWrapper { def apply[T](f: => T) : T = { val isSet = UrlLocalizer.currentLocale.set_? println(s"UrlLocalizer.currentLocale.set_? == $isSet")
LiftRules.earlyInStateful.append(req => { val isSet = UrlLocalizer.currentLocale.set_? println(s"UrlLocalizer.currentLocale.set_? == $isSet")
object UrlLocalizer extends Loggable { /** * What are the available locales? */ val locales: Map[String, Locale] = Map(Locale.getAvailableLocales.map(l => l.toString -> l) :_*) object currentLocale extends RequestVar[Box[Locale]](Empty) /** * Extract the locale */ def unapply(in: String): Option[Locale] = { val locale = locales.get(in) locale.foreach{l => currentLocale.set(Full(l)) } locale } /** * Calculate the Locale */ def calcLocale(in: Box[HTTPRequest]): Locale = { currentLocale.get match { case Full(locale) => // trace("calcLocale: using currentLocale.get: " + locale) locale case _ => val locale = in.flatMap(r => r.locale) match { case Full(reqLocale) => // trace("calcLocale: using Req.locale: " + reqLocale) reqLocale case _ => val defaultLocale = Locale.getDefault // trace("calcLocale: using Locale.getDefault: " + defaultLocale) defaultLocale } currentLocale.set(Full(locale)) locale } } }
override val rewrite: LocRewrite = Full(NamedPF("Admin stuff") { case RewriteRequest(ParsePath(UrlLocalizer(locale) :: "admin" :: Nil,_,_,_),_,_) => (RewriteResponse(templatePath, Map.empty, stopRewriting = true), Empty) })
LiftSession.onBeginServicing = ((session: LiftSession, req: Req) => {
// Do something here
}) :: LiftSession.onBeginServicing
Try using the lifecycle callbacks available in LiftSession. For ex.LiftSession.onBeginServicing = ((session: LiftSession, req: Req) => { // Do something here }) :: LiftSession.onBeginServicing
----Lift, the simply functional web framework: http://liftweb.netCode: http://github.com/liftDiscussion: http://groups.google.com/group/liftwebStuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code---You received this message because you are subscribed to the Google Groups "Lift" group.To unsubscribe from this group and stop receiving emails from it, send an email to liftweb+u...@googlegroups.com.For more options, visit https://groups.google.com/d/optout.
Y'all are hitting "Lift Archaeology". There were a lot of different approaches I took to request handling over time. Some are good and some are not-so-good. Sadly, there's all there... Maybe in Lift 4, we do a cleanup. :-)