Newer
Older
weather-servlet / src / main / scala / bootstrap / liftweb / Boot.scala
package bootstrap.liftweb

import net.liftweb.util._
import net.liftweb.http._
import net.liftweb.sitemap._
import net.liftweb.sitemap.Loc._
import Helpers._

import uk.org.floop.msc.wview.DataCollector
import uk.org.floop.msc.rest.{Graph, Dump}
 
/**
  * A class that's instantiated early and run.  It allows the application
  * to modify lift's environment
  */
class Boot {
  def boot {
    // where to search snippet
    LiftRules.addToPackages("uk.org.floop.msc")     

    val apiDispatcher: LiftRules.DispatchPf = {  
      case RequestMatcher(RequestState("graph" :: args, _) ,_) => graphApi(args)
      case RequestMatcher(RequestState("dump":: args, _), _) => dumpApi(args)
    } 
    LiftRules.statelessDispatchTable =   
      apiDispatcher orElse LiftRules.statelessDispatchTable  
    DataCollector.start()
  }
  
  private def graphApi  
    (args: List[String])
    (req: RequestState): Can[ResponseIt] =  
      Graph(args)

  private def dumpApi
    (args: List[String])
    (req: RequestState): Can[ResponseIt] =
      Dump(args)
    
}