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


Scala HttpRouter类代码示例

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


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

示例1: ServiceMain

//设置package包名称以及导入依赖的类
package io.github.mijicd.prezi

import com.twitter.finagle.http.{Request, Response}
import com.twitter.finatra.http.HttpServer
import com.twitter.finatra.http.filters.{CommonFilters, LoggingMDCFilter}
import com.twitter.finatra.http.routing.HttpRouter
import com.twitter.finatra.logging.modules.Slf4jBridgeModule
import io.github.mijicd.prezi.api.Presentations
import io.github.mijicd.prezi.modules.{DataSource, PreziJson}

object ServiceMain extends Service

class Service extends HttpServer {
  override protected def modules = Seq(Slf4jBridgeModule, DataSource)

  override protected def jacksonModule = PreziJson

  override protected def defaultFinatraHttpPort = ":8180"

  override protected def disableAdminHttpServer = true

  override protected def configureHttp(router: HttpRouter): Unit = router.
    filter[LoggingMDCFilter[Request, Response]].
    filter[CommonFilters].
    add[Presentations]
} 
开发者ID:mijicd,项目名称:finatra-demo,代码行数:27,代码来源:bootstrap.scala

示例2: ExampleServerMain

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

import com.twitter.finagle.http.{Response, Request}
import com.twitter.finatra.http.HttpServer
import com.twitter.finatra.http.filters.{CommonFilters, LoggingMDCFilter, TraceIdMDCFilter}
import com.twitter.finatra.http.routing.HttpRouter

object ExampleServerMain extends ExampleServer

class ExampleServer extends HttpServer {

  override def defaultFinatraHttpPort = ":9999"

  override def configureHttp(router: HttpRouter) {
    router
      .filter[LoggingMDCFilter[Request, Response]]
      .filter[TraceIdMDCFilter[Request, Response]]
      .filter[CommonFilters]
      .add[PingController]
  }

} 
开发者ID:divanvisagie,项目名称:finatra-website-example,代码行数:23,代码来源:ExampleServer.scala

示例3: ServerMain

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

import com.twitter.finagle.http.{Request, Response}
import com.twitter.finatra.http.HttpServer
import com.twitter.finatra.http.filters.{CommonFilters, LoggingMDCFilter, TraceIdMDCFilter}
import com.twitter.finatra.http.routing.HttpRouter
import $package$.controllers.MainController

object ServerMain extends Server

class Server extends HttpServer {
  override val name = "$package$ $name;format="Camel"$"

  override def configureHttp(router: HttpRouter) {
    router
      .filter[CommonFilters]
      .filter[LoggingMDCFilter[Request, Response]]
      .filter[TraceIdMDCFilter[Request, Response]]
      .add[MainController]
  }
} 
开发者ID:jimschubert,项目名称:finatra.g8,代码行数:22,代码来源:Server.scala

示例4: FinatraServerMain

//设置package包名称以及导入依赖的类
package com.github.ikhoon

import com.github.ikhoon.app.v1.fake.FakeController
import com.github.ikhoon.app.v1.ping.PingController
import com.github.ikhoon.app.v1.user.UserController
import com.github.ikhoon.modules._
import com.jakehschwartz.finatra.swagger.DocsController
import com.twitter.finagle.http.{ Request, Response }
import com.twitter.finatra.http.HttpServer
import com.twitter.finatra.http.filters.{ CommonFilters, LoggingMDCFilter, TraceIdMDCFilter }
import com.twitter.finatra.http.routing.HttpRouter

object FinatraServerMain extends FinatraServer

class FinatraServer extends HttpServer {

  override def modules = Seq(
    TypesafeConfigModule, QuillDatabaseModule, SlickDatabaseModule, SwaggerModule
  ) ++ HttpClientModules.modules

  override def jacksonModule = CustomJacksonModule

  override def defaultFinatraHttpPort = ":9999"

  override def configureHttp(router: HttpRouter) {
    router
      .filter[LoggingMDCFilter[Request, Response]]
      .filter[TraceIdMDCFilter[Request, Response]]
      .filter[CommonFilters]
      .add[DocsController]
      .add[PingController]
      .add[UserController]
      .add[FakeController]

  }

} 
开发者ID:ikhoon,项目名称:finatra-mysql-seed,代码行数:38,代码来源:FinatraServer.scala

示例5: ExampleServerMain

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

import com.twitter.finagle.http.{Response, Request}
import com.twitter.finatra.http.HttpServer
import com.twitter.finatra.http.filters.{CommonFilters, LoggingMDCFilter, TraceIdMDCFilter}
import com.twitter.finatra.http.routing.HttpRouter

object ExampleServerMain extends ExampleServer

class ExampleServer extends HttpServer {

  override def defaultFinatraHttpPort = ":9999"

  override def configureHttp(router: HttpRouter) {
    router
      .filter[LoggingMDCFilter[Request, Response]]
      .filter[TraceIdMDCFilter[Request, Response]]
      .filter[CommonFilters]
      .add[PingController]
      .add[HelloController]
      .add[AssetsController]
      .add[LoginController]
  }

} 
开发者ID:Sergey778,项目名称:finatra_test,代码行数:26,代码来源:ExampleServer.scala

示例6: TestClientServerMain

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

import java.net.InetSocketAddress

import com.sgtest.controllers.AuthenticationController
import com.twitter.finagle.Http
import com.twitter.finagle.http.{Request, Response}
import com.twitter.finagle.stats.DefaultStatsReceiver
import com.twitter.finagle.zipkin.thrift.ZipkinTracer
import com.twitter.finatra.http.HttpServer
import com.twitter.finatra.http.filters.{CommonFilters, LoggingMDCFilter, TraceIdMDCFilter}
import com.twitter.finatra.http.routing.HttpRouter


object TestClientServerMain extends TestClientServer

class TestClientServer extends HttpServer {

  override def defaultFinatraHttpPort = ":8888"

  override val adminPort = flag("admin.port", new InetSocketAddress(8880), "Admin Http server port")

  override def configureHttp(router: HttpRouter) {
    router
      .filter[LoggingMDCFilter[Request, Response]]
      .filter[TraceIdMDCFilter[Request, Response]]
      .filter[CommonFilters]
      .add[AuthenticationController]
  }

  override def configureHttpServer(server: Http.Server): Http.Server = {
    val receiver = DefaultStatsReceiver.get
    val zipkinHost = sys.env.getOrElse("SG_ZIPKIN_HOST","localhost")
    val zipkinPort = sys.env.getOrElse("SG_ZIPKIN_PORT", "9410").toInt
    val tracer = ZipkinTracer.mk(
      host = zipkinHost,
      port = zipkinPort,
      statsReceiver = receiver
    )
    server
        .withTracer(tracer)
        .withLabel("test-client-server")
  }

} 
开发者ID:divanvisagie,项目名称:swiss-guard,代码行数:46,代码来源:TestClientServer.scala

示例7: FitmanApp

//设置package包名称以及导入依赖的类
import com.twitter.finagle.http.Request
import com.twitter.finatra.http.routing.HttpRouter
import com.twitter.finatra.http.{Controller, HttpServer}

object FitmanApp extends FitmanServer

class FitmanServer extends HttpServer {
  override protected def configureHttp(router: HttpRouter): Unit = {
    router.add(new HelloController)
  }
}

class HelloController extends Controller {

  get("/hello") { request: Request =>
    "Fitman says hello"
  }

} 
开发者ID:simoncyl,项目名称:Fitman,代码行数:20,代码来源:FitmanApp.scala

示例8: ExampleServerMain

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

import com.twitter.finagle.http.{Response, Request}
import com.twitter.finatra.http.HttpServer
import com.twitter.finatra.http.filters.CommonFilters
import com.twitter.finatra.http.routing.HttpRouter
import com.twitter.finatra.logging.filter.{TraceIdMDCFilter, LoggingMDCFilter}
import com.twitter.finatra.logging.modules.LogbackModule

object ExampleServerMain extends ExampleServer

class ExampleServer extends HttpServer {

  override def modules = Seq(LogbackModule)

  override def configureHttp(router: HttpRouter) {
    router
      .filter[LoggingMDCFilter[Request, Response]]
      .filter[TraceIdMDCFilter[Request, Response]]
      .filter[CommonFilters]
      .add[PingController]
  }

} 
开发者ID:cocodrino,项目名称:futureEitherFinatra,代码行数:25,代码来源:ExampleServer.scala

示例9: ApiServer

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

import com.twitter.finagle.http.{Request, Response}
import com.twitter.finatra.http.HttpServer
import com.twitter.finatra.http.filters.{CommonFilters, LoggingMDCFilter, TraceIdMDCFilter}
import com.twitter.finatra.http.routing.HttpRouter
import xpoint.api._
import xpoint.api.exception.RootExceptionMapper
import xpoint.api.service.TokenService
import xpoint.engine.script.ScriptEngine
import xpoint.engine.script.service.ScriptHook



class ApiServer()
               (
                 implicit val tokenService: TokenService,
                 implicit val scriptEngine: ScriptEngine,
                 implicit val scriptHook: ScriptHook
               ) extends HttpServer{

  override protected def configureHttp(router: HttpRouter): Unit = {
    router
      .filter[LoggingMDCFilter[Request, Response]]
      .filter[TraceIdMDCFilter[Request, Response]]
      .filter[CommonFilters]
//      .add(new ScriptCrud(injector.instance[MessageBodyManager]))
//      .add(new ScriptFileUpload)
      .add(new ScriptDataSource)
//      .add(new ScriptDebug)
//      .add(new ScriptRegister)
//      .add(new ChartSource)
      .exceptionMapper[RootExceptionMapper]
  }
} 
开发者ID:super-point,项目名称:xpoint-core,代码行数:36,代码来源:ApiServer.scala

示例10: MainServer

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

import com.twitter.finagle.http.{Request, Response}
import com.twitter.finatra.http.HttpServer
import com.twitter.finatra.http.filters.{CommonFilters, LoggingMDCFilter, TraceIdMDCFilter}
import com.twitter.finatra.http.routing.HttpRouter
import com.versus.module.RepositoryModule

object MainServer extends VersusServer

class VersusServer extends HttpServer {

  override def defaultFinatraHttpPort = ":9999"

  override def configureHttp(router: HttpRouter) {
    router
      .filter[LoggingMDCFilter[Request, Response]]
      .filter[TraceIdMDCFilter[Request, Response]]
      .filter[CommonFilters]
      .add[PingController]
      .add[DashboardController]
  }

  override val modules = Seq(
    RepositoryModule)


} 
开发者ID:previousdeveloper,项目名称:open-versus,代码行数:29,代码来源:VersusServer.scala

示例11: FeederApiServerMain

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

import com.jensraaby.feeder.api.controllers.IndexController
import com.twitter.finagle.http.{Request, Response}
import com.twitter.finatra.http.HttpServer
import com.twitter.finatra.http.filters.{CommonFilters, LoggingMDCFilter, TraceIdMDCFilter}
import com.twitter.finatra.http.routing.HttpRouter

object FeederApiServerMain extends FeederApiServer

class FeederApiServer extends HttpServer {

  override def configureHttp(router: HttpRouter): Unit = {
    router.
      filter[LoggingMDCFilter[Request, Response]].
      filter[TraceIdMDCFilter[Request, Response]].
      filter[CommonFilters].
      add[IndexController]
  }
} 
开发者ID:jensraaby,项目名称:feeder,代码行数:21,代码来源:FeederApiServer.scala

示例12: Server

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

import com.twitter.finagle.http.{Request, Response}
import com.twitter.finatra.http.HttpServer
import com.twitter.finatra.http.filters._
import com.twitter.finatra.http.routing.HttpRouter

class Server extends HttpServer {
  override val name = "api-server"

  override val modules = Seq(ApiModule)

  override def configureHttp(router: HttpRouter): Unit = {
    router
      .filter[LoggingMDCFilter[Request, Response]]
      .filter[TraceIdMDCFilter[Request, Response]]
      .filter[CommonFilters]
      .add[ApiController]
  }
}

object ServerMain extends Server 
开发者ID:GlobalNamesArchitecture,项目名称:gnindex,代码行数:23,代码来源:Server.scala

示例13: XTestServer

//设置package包名称以及导入依赖的类
package gov.nih.nlm.ncbi.xheadersfilter

import com.twitter.finagle.http.{Request, Response}
import com.twitter.finatra.http.HttpServer
import com.twitter.finatra.http.filters.{CommonFilters, LoggingMDCFilter, TraceIdMDCFilter}
import com.twitter.finatra.http.routing.HttpRouter



class XTestServer extends HttpServer{

  override def configureHttp(router: HttpRouter) {
    router
      .filter[LoggingMDCFilter[Request, Response]]
      .filter[TraceIdMDCFilter[Request, Response]]
      .filter[CommonFilters]
      .filter[XHeadersHttpResponseFilter[Request]]
      .add[XTestController]
  }

} 
开发者ID:ncbi,项目名称:finatra-xheaders-filter,代码行数:22,代码来源:XTestServer.scala

示例14: AuthServerMain

//设置package包名称以及导入依赖的类
package xyz.lascuolaopensource.coo2xyz.auth

import com.twitter.finagle.http.{Request, Response}
import com.twitter.finatra.http.HttpServer
import com.twitter.finatra.http.filters.{CommonFilters, LoggingMDCFilter, TraceIdMDCFilter}
import com.twitter.finatra.http.routing.HttpRouter
import com.typesafe.config.ConfigFactory
import org.flywaydb.core.Flyway
import slick.jdbc.DatabaseUrlDataSource
import xyz.lascuolaopensource.coo2xyz.auth.controllers.{AssetsController, AuthController}
import xyz.lascuolaopensource.coo2xyz.auth.filters.SessionFilter


object AuthServerMain extends AuthServer {

	private[auth] val config = ConfigFactory.load()

	override protected def start() = {
		val flyway = new Flyway
		val dbSource = new DatabaseUrlDataSource
		dbSource.setUrl(config.getString("pgdb.properties.url"))
		flyway.setDataSource(dbSource)
		flyway.baseline()
		flyway.migrate

		super.start
	}

}

class AuthServer extends HttpServer {

	override protected def defaultFinatraHttpPort = AuthServerMain.config.getString("http.port")

	override def defaultHttpPort = AuthServerMain.config.getString("http.port").tail.toInt

	override protected def disableAdminHttpServer = true

	override protected def configureHttp(router: HttpRouter) = {
		router
			.filter[LoggingMDCFilter[Request, Response]]
			.filter[TraceIdMDCFilter[Request, Response]]
			.filter[CommonFilters]
			.add[SessionFilter, AuthController]
			.add[AssetsController]
	}

} 
开发者ID:coompany,项目名称:coo2xyz-auth,代码行数:49,代码来源:AuthServer.scala

示例15: ExampleServerMain

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

import com.github.xiaodongw.swagger.finatra.SwaggerController
import com.twitter.finagle.http.{Request, Response}
import com.twitter.finatra.http.HttpServer
import com.twitter.finatra.http.filters.{CommonFilters, LoggingMDCFilter, TraceIdMDCFilter}
import com.twitter.finatra.http.routing.HttpRouter

object ExampleServerMain extends ExampleServer

class ExampleServer extends HttpServer {

  override def defaultFinatraHttpPort = ":9999"

  override def configureHttp(router: HttpRouter) : Unit = {
    router
      .filter[LoggingMDCFilter[Request, Response]]
      .filter[TraceIdMDCFilter[Request, Response]]
      .filter[CommonFilters]
      .add(new SwaggerController(swagger = FinatraSwaggerDocument))
      .add[PingController]
  }

} 
开发者ID:divanvisagie,项目名称:finagle-http-example,代码行数:25,代码来源:ExampleServer.scala


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