当前位置: 首页>>代码示例>>Scala>>正文


Scala SimpleRouter类代码示例

本文整理汇总了Scala中play.api.routing.SimpleRouter的典型用法代码示例。如果您正苦于以下问题:Scala SimpleRouter类的具体用法?Scala SimpleRouter怎么用?Scala SimpleRouter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SimpleRouter类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。

示例1: LocationRouter

//设置package包名称以及导入依赖的类
package controllers.location

import javax.inject.Inject

import play.api.routing.Router.Routes
import play.api.routing.SimpleRouter
import play.api.routing.sird._

class LocationRouter @Inject()(addressTypeCtrl: AddressTypeCtrl,
                               locationTypeCtrl: LocationTypeCtrl,
                               contactTypeCtrl: ContactTypeCtrl)
    extends SimpleRouter {
  override def routes: Routes = {
    //address
    case GET(p"/addresstype/all") =>
      addressTypeCtrl.getAll
    case GET(p"/addresstype/$id") =>
      addressTypeCtrl.getById(id)
    case POST(p"/addresstype/create") =>
      addressTypeCtrl.create

    //location type
    case GET(p"/locationtype/all") =>
      locationTypeCtrl.getAll
    case GET(p"/locationtype/$id") =>
      locationTypeCtrl.getById(id)
    case POST(p"/locationtype/create") =>
      locationTypeCtrl.create

    //contact type
    case GET(p"/contacttype/all") =>
      contactTypeCtrl.getAll
    case GET(p"/contacttype/$id") =>
      contactTypeCtrl.getById(id)
    case POST(p"/contacttype/create") =>
      contactTypeCtrl.create

  }
} 
开发者ID:boniface,项目名称:infoshareapi,代码行数:40,代码来源:LocationRouter.scala

示例2: UserRouter

//设置package包名称以及导入依赖的类
package v1.user

import javax.inject.Inject
import play.api.routing.Router.Routes
import play.api.routing.SimpleRouter
import play.api.routing.sird._

class UserRouter @Inject()(controller: UserController) 
  extends SimpleRouter {
  
  var prefix = "/v1/users"
  
  def link(id: UserId): String = {
    import com.netaporter.uri.dsl._
    val url = prefix / id.toString
    url.toString()
  }
  
  override def routes: Routes = {
    case GET(p"/") =>
      controller.index

    case POST(p"/") =>
      controller.process

    case GET(p"/$id") =>
      controller.show(id)
       
      
  }
} 
开发者ID:heinrich10,项目名称:scala-mvc-sample,代码行数:32,代码来源:UserRouter.scala

示例3: OrganisationRouter

//设置package包名称以及导入依赖的类
package controllers.organisations                                                                                                                                                 //Xolela Masebeni(213160447) [email protected]

import javax.inject.Inject

import play.api.routing.Router.Routes
import play.api.routing.SimpleRouter
import play.api.routing.sird._


class OrganisationRouter @Inject()
(mail: OrganisationController)
  extends SimpleRouter {
  override def routes: Routes = {
    case GET(p"/organisation/$org") =>
      mail.getOrganisation(org)
    case POST(p"/organisation/create") =>
      mail.createOrUpdate
  }
} 
开发者ID:boniface,项目名称:hworkapi,代码行数:20,代码来源:OrganisationRouter.scala

示例4: UtilRouter

//设置package包名称以及导入依赖的类
package controllers.common.util

import javax.inject.Inject

import play.api.routing.Router.Routes
import play.api.routing.SimpleRouter
import play.api.routing.sird._


class UtilRouter @Inject()
(mail: MailController)
  extends SimpleRouter {
  override def routes: Routes = {
    case GET(p"/mail/$org") =>
      mail.getMail(org)
    case POST(p"/mail/create") =>
      mail.createOrUpdate
  }
} 
开发者ID:boniface,项目名称:hworkapi,代码行数:20,代码来源:UtilRouter.scala

示例5: PostRouter

//设置package包名称以及导入依赖的类
package v1.post

import javax.inject.Inject

import play.api.routing.Router.Routes
import play.api.routing.SimpleRouter
import play.api.routing.sird._


class PostRouter @Inject()(controller: PostController)
  extends SimpleRouter {
  val prefix = "/v1/posts"

  def link(id: PostId): String = {
    import com.netaporter.uri.dsl._
    val url = prefix / id.toString
    url.toString()
  }

  override def routes: Routes = {
    case GET(p"/") =>
      controller.index

    case POST(p"/") =>
      controller.process

    case GET(p"/$id") =>
      controller.show(id)
  }

} 
开发者ID:TrungSpy,项目名称:scala-api-lib,代码行数:32,代码来源:PostRouter.scala

示例6: UtilRouter

//设置package包名称以及导入依赖的类
package controllers.util

import javax.inject.Inject

import play.api.routing.Router.Routes
import play.api.routing.SimpleRouter
import play.api.routing.sird._

class UtilRouter @Inject()(roleController: RoleController)(
    keysController: KeysController)(
    mailSettingsController: MailSettingsController,
    itemsStatusCtrl: ItemsStatusCtrl)
    extends SimpleRouter {
  override def routes: Routes = {

    //ROLES
    case GET(p"/roles/all") =>
      roleController.getRoles
    case POST(p"/roles/create") =>
      roleController.create
    case GET(p"/roles/$id") =>
      roleController.getRoleById(id)

 //items status
    case POST(p"/roles/create") =>
      itemsStatusCtrl.create
    case GET(p"/roles/$id") =>
      itemsStatusCtrl.getById(id)

    //KEYS
    case GET(p"/keys/all") =>
      keysController.getKeys
    case POST(p"/keys/create") =>
      keysController.create
    case GET(p"/keys/$id") =>
      keysController.getKeyById(id)

    //MAIL
    case GET(p"/mail/all/$siteId") =>
      mailSettingsController.getSiteMailSettings(siteId)
    case POST(p"/mail/create") =>
      mailSettingsController.create
    case GET(p"/mail/$siteId/$id") =>
      mailSettingsController.getMailSettingById(siteId, id)

  }
} 
开发者ID:boniface,项目名称:infoshareapi,代码行数:48,代码来源:UtilRouter.scala

示例7: StorageRouter

//设置package包名称以及导入依赖的类
package controllers.storage

import javax.inject.Inject

import play.api.routing.Router.Routes
import play.api.routing.SimpleRouter
import play.api.routing.sird._

class StorageRouter @Inject()(storageUrlCtrl: StorageUrlCtrl,
                              fileResultsCtrl: FileResultsCtrl)
    extends SimpleRouter {
  override def routes: Routes = {
    //storage url
    case GET(p"/storageurl/all") =>
      storageUrlCtrl.getAll
    case GET(p"/storageurl/$id") =>
      storageUrlCtrl.getById(id)
    case POST(p"/storageurl/create") =>
      storageUrlCtrl.create

    //file result
    case GET(p"/fileresult/all") =>
      fileResultsCtrl.getAll
    case GET(p"/fileresult/$id") =>
      fileResultsCtrl.getById(id)
    case POST(p"/fileresult/create") =>
      fileResultsCtrl.create

  }
} 
开发者ID:boniface,项目名称:infoshareapi,代码行数:31,代码来源:StorageRouter.scala

示例8: Router

//设置package包名称以及导入依赖的类
package controllers

import javax.inject.Inject
import lib.Constants
import play.api.routing.SimpleRouter
import play.api.http._
import play.api.mvc._
import scala.runtime.AbstractPartialFunction


class Router @Inject() (
  internal: Internal,
  proxy: ReverseProxy
) extends SimpleRouter {

  override def routes = new AbstractPartialFunction[RequestHeader, Handler] {
    override def applyOrElse[A <: RequestHeader, B >: Handler](request: A, default: A => B) = {
      (request.method, request.path, request.headers.get(Constants.Headers.FlowServer)) match {
        case ("GET", "/_internal_/healthcheck", None) => internal.getHealthcheck
        case ("GET", "/_internal_/config", None) => internal.getConfig
        case ("GET", "/_internal_/route", None) => internal.getRoute()
        case ("GET", "/favicon.ico", None) => internal.favicon
        case (_, "/_internal_/diagnostics", None) => internal.diagnostics
        case ("GET", "/robots.txt", None) => internal.getRobots
        case _ => proxy.handle
      }
    }

    override def isDefinedAt(rh: RequestHeader) = true
  }

} 
开发者ID:flowvault,项目名称:proxy,代码行数:33,代码来源:RequestHandler.scala

示例9: SystemLogRouter

//设置package包名称以及导入依赖的类
package controllers.syslog

import javax.inject.Inject

import play.api.routing.Router.Routes
import play.api.routing.SimpleRouter
import play.api.routing.sird._

class SystemLogRouter @Inject()(syslogCtrl: SystemLogEventsCtrl)
    extends SimpleRouter {
  override def routes: Routes = {
    //System Log Events
    case GET(p"/systemlog/all/$org") =>
      syslogCtrl.getAll(org)
    case GET(p"/systemlog/$org/$id") =>
      syslogCtrl.getById(org, id)
    case POST(p"/systemlog/create") =>
      syslogCtrl.create
  }
} 
开发者ID:boniface,项目名称:infoshareapi,代码行数:21,代码来源:SystemLogRouter.scala

示例10: OrganisationRouter

//设置package包名称以及导入依赖的类
package controllers.organisation

import javax.inject.Inject

import play.api.routing.Router.Routes
import play.api.routing.SimpleRouter
import play.api.routing.sird._

class OrganisationRouter @Inject()(locationCtrl: LocationCtrl,
                                   organisationCtrl: OrganisationCtrl,
                                   organisationLogoCtrl: OrganisationLogoCtrl)
    extends SimpleRouter {
  override def routes: Routes = {
    //location
    case GET(p"/location/all/$org") =>
      locationCtrl.getAll(org)
    case GET(p"/location/$org/$id") =>
      locationCtrl.getById(org, id)
    case POST(p"/location/delete/$org/$id") =>
      locationCtrl.delete(org, id)
    case POST(p"/location/create") =>
      locationCtrl.create

    //organisation logo
    case GET(p"/organisationlogo/all/$org") =>
      organisationLogoCtrl.getAll(org)
    case GET(p"/organisationlogo/$org/$id") =>
      organisationLogoCtrl.getById(org, id)
    case POST(p"/organisationlogo/create") =>
      organisationLogoCtrl.create

    //organisation
    case GET(p"/organisation/all") =>
      organisationCtrl.getAll
    case GET(p"/organisation/$id") =>
      organisationCtrl.getById(id)
    case POST(p"/organisation/create") =>
      organisationCtrl.create
  }
} 
开发者ID:boniface,项目名称:infoshareapi,代码行数:41,代码来源:OrganisationRouter.scala

示例11: BobRouter

//设置package包名称以及导入依赖的类
package v1.bob

import javax.inject.Inject

import play.api.routing.Router.Routes
import play.api.routing.SimpleRouter
import play.api.routing.sird._

class BobRouter @Inject()(
                           controller: BobController,
                           interactionController: BobInterActionController
                         )
  extends SimpleRouter {
  val prefix = "/slack/bob"

  def link(id: Int): String = {
    import com.netaporter.uri.dsl._
    val url = prefix / id.toString
    url.toString()
  }

  override def routes: Routes = {
    case GET(p"/") => controller.index
    case POST(p"/") => controller.process
    case POST(p"/im") => interactionController.process
  }
} 
开发者ID:ridi-data,项目名称:Bob,代码行数:28,代码来源:BobRouter.scala

示例12: CustomRouter

//设置package包名称以及导入依赖的类
package api

import javax.inject.{Inject, Named}

import akka.actor.ActorRef
import com.viajobien.busy.actors.ProducerActor
import play.api.Logger
import play.api.libs.json.{JsNull, Json}
import play.api.mvc.Action
import play.api.mvc.Results._
import play.api.routing.Router.Routes
import play.api.routing.SimpleRouter
import repositories.RouteRepository
import services.RouteService

import scala.concurrent.{ExecutionContext, Future}


class CustomRouter @Inject()(@Named(ProducerActor.name) producerActor: ActorRef,
                             routeService: RouteService, routeRepository: RouteRepository
                            )(implicit ec: ExecutionContext) extends SimpleRouter {

  override def routes: Routes = {
    case _ =>
      Action.async { implicit request =>
        val future = this.routeService.route(
          futureJson => futureJson map {
            case JsNull => ServiceUnavailable(Json.obj("error" -> "Error on access service"))
            case json   => Ok(json)
          },
          () => Future.successful(BadGateway(Json.obj("error" -> "route not found")))
        )

        future recover {
          case e =>
            Logger.warn("error on getRoute", e)
            ServiceUnavailable(Json.obj("error" -> "error calling route"))
        }
      }
  }

} 
开发者ID:viajobien,项目名称:busy-example,代码行数:43,代码来源:CustomRouter.scala

示例13: BaseAppModule

//设置package包名称以及导入依赖的类
import controllers._

import scaldi.Module

import akka.actor.ActorSystem

import play.api.http._
import play.api.ApplicationLoader.Context
import play.api.inject.ApplicationLifecycle
import play.api.routing.{Router, SimpleRouter}
import play.api.{Application, BuiltInComponentsFromContext, Configuration, Environment}

class BaseAppModule(aContext: Context) extends Module {
  bind[Router]               to injected[router.Routes]
  bind[Context]              to aContext
  bind[Application]          to inject[BuiltInComponentsFromContext].application
  bind[ActorSystem]          to inject[Application].actorSystem
  bind[Environment]          to aContext.environment
  bind[Configuration]        to aContext.initialConfiguration
  bind[ApplicationLifecycle] to aContext.lifecycle

  bind[AssetsBuilder]        to controllers.Assets
  bind[AssetsMetadata]       to injected[AssetsMetadataProvider].get
  bind[AssetsConfiguration]  to AssetsConfiguration()

  bind[FileMimeTypes]        to new DefaultFileMimeTypesProvider(inject[HttpConfiguration].fileMimeTypes).get
  bind[HttpErrorHandler]     to DefaultHttpErrorHandler
  bind[HttpConfiguration]    to HttpConfiguration.fromConfiguration(inject[Configuration],inject[Environment])

  bind[BuiltInComponentsFromContext] to new BuiltInComponentsFromContext(inject[Context]) {
    implicit val lInjector = BaseAppModule.this
    override def router    = SimpleRouter{case x => inject[Router].routes(x)}
  }
} 
开发者ID:andu125,项目名称:CatChow,代码行数:35,代码来源:BaseAppModule.scala


注:本文中的play.api.routing.SimpleRouter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。