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


Scala MediaType类代码示例

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


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

示例1: DataResourceService

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

import com.martinsnyder.api.DataResourceApi.AnyDataResourceApi
import com.martinsnyder.api._
import javax.ws.rs.{ GET, Path, PathParam, Produces }
import javax.ws.rs.core.{ MediaType, Response }

abstract class DataResourceService(api: AnyDataResourceApi) extends Service {
  @GET
  @Produces(Array(MediaType.APPLICATION_JSON))
  def query(): Response =
    toResponseBuilder(api.query()).build()

  @GET
  @Path("/{id}")
  @Produces(Array(MediaType.APPLICATION_JSON))
  def retrieve(@PathParam("id") id: ResourceId): Response =
    toResponseBuilder(api.retrieve(id)).build()

  @GET
  @Path("/{id}/pointer")
  @Produces(Array(MediaType.APPLICATION_JSON))
  def resourcePointer(@PathParam("id") id: ResourceId): Response =
    toResponseBuilder(api.resourcePointer(id)).build()
} 
开发者ID:MartinSnyder,项目名称:mrp,代码行数:26,代码来源:DataResourceService.scala

示例2: CertificateResponse

//设置package包名称以及导入依赖的类
// Copyright (C) 2016 Grier Forensics. All Rights Reserved.
package com.grierforensics.greatdane

import javax.ws.rs._
import javax.ws.rs.core.{MediaType, Response}

case class CertificateResponse(certificates: Seq[CertificateDetails])
case class ZoneLineResponse(zoneLines: Seq[String])

@Path("/")
@Produces(Array(MediaType.APPLICATION_JSON))
class Resource(engine: Engine) {

  val genson = GensonConfig.genson

  
  @POST
  @Path("{email}/dnsZoneLineForCert")
  def dnsZoneLine(@PathParam("email") email: String, pemEncodedCertificate: String): String = {
    val zoneLine = engine.dnsZoneLine(email, pemEncodedCertificate)
    genson.serialize(zoneLine)
  }
} 
开发者ID:grierforensics,项目名称:Great-DANE-Engine,代码行数:24,代码来源:Resource.scala

示例3: InsecureClient

//设置package包名称以及导入依赖的类
package uk.gov.hmrc.utils

import com.sun.jersey.api.client.{Client, ClientResponse}
import org.json4s.jackson.Serialization._
import javax.ws.rs.core.MediaType
import javax.net.ssl.{HostnameVerifier, SSLContext, SSLSession, X509TrustManager}

import com.sun.jersey.api.client.config.DefaultClientConfig
import com.sun.jersey.client.urlconnection.HTTPSProperties
import java.security.cert.X509Certificate

import com.sun.jersey.api.client.filter.GZIPContentEncodingFilter

class InsecureClient {

  implicit val defaultFormats = json.JsonExtraction.formats

  private val jsonContentType = MediaType.APPLICATION_JSON + ";charset=utf-8"

  private val sslContext = SSLContext.getInstance("SSL")
  sslContext.init(null, Array(new InsecureTrustManager), null)

  private val config = new DefaultClientConfig()

  config.getProperties.put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, new HTTPSProperties(
    new HostnameVerifier() {
      override def verify(s: String, sslSession: SSLSession): Boolean = true
    },
    sslContext
  ))


  private val client = Client.create(config)
  client.addFilter(new GZIPContentEncodingFilter(false))

  def get[A](url: String)(implicit m: Manifest[A]): A = {
    val response = client.resource(url).accept(jsonContentType).get[ClientResponse](classOf[ClientResponse])
    val responseBody = response.getEntity(classOf[String])
    println(s"TARGET = $url")
    response.getStatus match {
      case 200 => read[A](responseBody)
      case _ => throw new RuntimeException(s"Unexpected response from $url, status code ${response.getStatus} : $responseBody")
    }
  }

  def getRawResponse(url: String, contentType: String = jsonContentType)(implicit m: Manifest[String]): (Int, String) = {
    val response = client.resource(url).accept(contentType).get[ClientResponse](classOf[ClientResponse])
    val responseBody = response.getEntity(classOf[String])
    val status = response.getStatus
    (status, responseBody)
  }
}

class InsecureTrustManager extends X509TrustManager {
  def checkClientTrusted(p1: Array[X509Certificate], p2: String) {}

  def checkServerTrusted(p1: Array[X509Certificate], p2: String) {}

  def getAcceptedIssuers: Array[X509Certificate] = Array()
} 
开发者ID:danewatts,项目名称:zap-automation,代码行数:61,代码来源:InsecureClient.scala

示例4: SystemResource

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

import java.io.StringWriter
import java.util.concurrent.TimeUnit
import javax.servlet.http.HttpServletRequest
import javax.ws.rs._
import javax.ws.rs.core.{ Context, MediaType, Response }

import com.codahale.metrics.{ MetricFilter, MetricRegistry }
import com.codahale.metrics.annotation.Timed
import com.codahale.metrics.json.MetricsModule
import com.fasterxml.jackson.databind.ObjectMapper
import com.google.inject.Inject
import mesosphere.marathon.MarathonConf
import mesosphere.marathon.io.IO
import mesosphere.marathon.plugin.auth.AuthorizedResource.SystemConfig
import mesosphere.marathon.plugin.auth.{ Authenticator, Authorizer, ViewResource }


@Path("")
@Consumes(Array(MediaType.APPLICATION_JSON))
@Produces(Array(MarathonMediaType.PREFERRED_APPLICATION_JSON))
class SystemResource @Inject() (metrics: MetricRegistry, val config: MarathonConf)(implicit
  val authenticator: Authenticator,
    val authorizer: Authorizer) extends RestResource with AuthResource {

  private[this] lazy val mapper = new ObjectMapper().registerModule(
    new MetricsModule(TimeUnit.SECONDS, TimeUnit.SECONDS, false, MetricFilter.ALL)
  )

  @GET
  @Path("ping")
  @Timed
  def ping(@Context req: HttpServletRequest): Response = authenticated(req) { implicit identity =>
    withAuthorization(ViewResource, SystemConfig){
      ok("pong")
    }
  }

  @GET
  @Path("metrics")
  @Timed
  def metrics(@Context req: HttpServletRequest): Response = authenticated(req) { implicit identity =>
    withAuthorization(ViewResource, SystemConfig){
      IO.using(new StringWriter()) { writer =>
        mapper.writer().writeValue(writer, metrics)
        ok(writer.toString)
      }
    }
  }
} 
开发者ID:xiaozai512,项目名称:marathon,代码行数:52,代码来源:SystemResource.scala

示例5: QueueResource

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

import javax.inject.Inject
import javax.servlet.http.HttpServletRequest
import javax.ws.rs._
import javax.ws.rs.core.{ Context, MediaType, Response }

import com.codahale.metrics.annotation.Timed
import mesosphere.marathon.MarathonConf
import mesosphere.marathon.api.{ AuthResource, MarathonMediaType }
import mesosphere.marathon.core.base.Clock
import mesosphere.marathon.core.launchqueue.LaunchQueue
import mesosphere.marathon.plugin.auth.{ Authenticator, Authorizer, UpdateRunSpec, ViewRunSpec }
import mesosphere.marathon.state.PathId._
import mesosphere.marathon.raml.Raml

@Path("v2/queue")
@Consumes(Array(MediaType.APPLICATION_JSON))
class QueueResource @Inject() (
    clock: Clock,
    launchQueue: LaunchQueue,
    val authenticator: Authenticator,
    val authorizer: Authorizer,
    val config: MarathonConf) extends AuthResource {

  @GET
  @Timed
  @Produces(Array(MarathonMediaType.PREFERRED_APPLICATION_JSON))
  def index(@Context req: HttpServletRequest, @QueryParam("embed") embed: java.util.Set[String]): Response = authenticated(req) { implicit identity =>
    val embedLastUnusedOffers = embed.contains(QueueResource.EmbedLastUnusedOffers)
    val infos = launchQueue.listWithStatistics.filter(t => t.inProgress && isAuthorized(ViewRunSpec, t.runSpec))
    ok(Raml.toRaml((infos, embedLastUnusedOffers, clock)))
  }

  @DELETE
  @Path("""{appId:.+}/delay""")
  def resetDelay(
    @PathParam("appId") id: String,
    @Context req: HttpServletRequest): Response = authenticated(req) { implicit identity =>
    val appId = id.toRootPath
    val maybeApp = launchQueue.list.find(_.runSpec.id == appId).map(_.runSpec)
    withAuthorization(UpdateRunSpec, maybeApp, notFound(s"Application $appId not found in tasks queue.")) { app =>
      launchQueue.resetDelay(app)
      noContent
    }
  }
}

object QueueResource {
  val EmbedLastUnusedOffers = "lastUnusedOffers"
} 
开发者ID:xiaozai512,项目名称:marathon,代码行数:52,代码来源:QueueResource.scala

示例6: DeploymentsResource

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

import javax.inject.Inject
import javax.servlet.http.HttpServletRequest
import javax.ws.rs._
import javax.ws.rs.core.Response.Status._
import javax.ws.rs.core.{ Context, MediaType, Response }

import mesosphere.marathon.api.v2.json.Formats._
import mesosphere.marathon.api.{ AuthResource, MarathonMediaType }
import mesosphere.marathon.core.group.GroupManager
import mesosphere.marathon.plugin.auth._
import mesosphere.marathon.{ MarathonConf, MarathonSchedulerService }
import mesosphere.util.Logging

@Path("v2/deployments")
@Consumes(Array(MediaType.APPLICATION_JSON))
@Produces(Array(MarathonMediaType.PREFERRED_APPLICATION_JSON))
class DeploymentsResource @Inject() (
  service: MarathonSchedulerService,
  groupManager: GroupManager,
  val authenticator: Authenticator,
  val authorizer: Authorizer,
  val config: MarathonConf)
    extends AuthResource
    with Logging {

  @GET
  def running(@Context req: HttpServletRequest): Response = authenticated(req) { implicit identity =>
    val infos = result(service.listRunningDeployments())
      .filter(_.plan.affectedRunSpecs.exists(isAuthorized(ViewRunSpec, _)))
    ok(infos)
  }

  @DELETE
  @Path("{id}")
  def cancel(
    @PathParam("id") id: String,
    @DefaultValue("false")@QueryParam("force") force: Boolean,
    @Context req: HttpServletRequest): Response = authenticated(req) { implicit identity =>
    val plan = result(service.listRunningDeployments()).find(_.plan.id == id).map(_.plan)
    plan.fold(notFound(s"DeploymentPlan $id does not exist")) { deployment =>
      deployment.affectedRunSpecs.foreach(checkAuthorization(UpdateRunSpec, _))

      if (force) {
        // do not create a new deployment to return to the previous state
        log.info(s"Canceling deployment [$id]")
        service.cancelDeployment(id)
        status(ACCEPTED) // 202: Accepted
      } else {
        // create a new deployment to return to the previous state
        deploymentResult(result(groupManager.updateRoot(
          deployment.revert,
          force = true
        )))
      }
    }
  }
} 
开发者ID:xiaozai512,项目名称:marathon,代码行数:60,代码来源:DeploymentsResource.scala

示例7: SchemaResource

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

import java.io.InputStream
import javax.inject.Inject
import javax.ws.rs._
import javax.ws.rs.core.MediaType

import com.codahale.metrics.annotation.Timed
import mesosphere.marathon.MarathonConf
import mesosphere.marathon.api.{ MarathonMediaType, RestResource }

@Path("v2/schemas")
@Consumes(Array(MediaType.APPLICATION_JSON))
@Produces(Array(MarathonMediaType.PREFERRED_APPLICATION_JSON))
class SchemaResource @Inject() (
    val config: MarathonConf) extends RestResource {

  //TODO: schemas are available via /public/api/v2/schema/* anyway
  @GET
  @Timed
  @Path("app")
  def index(): InputStream = {
    getClass.getResourceAsStream("/public/api/v2/schema/AppDefinition.json")
  }
} 
开发者ID:xiaozai512,项目名称:marathon,代码行数:26,代码来源:SchemaResource.scala

示例8: AppVersionsResource

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

import javax.servlet.http.HttpServletRequest
import javax.ws.rs._
import javax.ws.rs.core.{ Context, MediaType, Response }

import com.codahale.metrics.annotation.Timed
import mesosphere.marathon.api.v2.json.Formats._
import mesosphere.marathon.api.{ AuthResource, MarathonMediaType }
import mesosphere.marathon.core.group.GroupManager
import mesosphere.marathon.plugin.auth.{ Authenticator, Authorizer, ViewRunSpec }
import mesosphere.marathon.state.PathId._
import mesosphere.marathon.state.Timestamp
import mesosphere.marathon.{ MarathonConf, MarathonSchedulerService }
import org.slf4j.LoggerFactory

@Produces(Array(MarathonMediaType.PREFERRED_APPLICATION_JSON))
@Consumes(Array(MediaType.APPLICATION_JSON))
class AppVersionsResource(
    service: MarathonSchedulerService,
    groupManager: GroupManager,
    val authenticator: Authenticator,
    val authorizer: Authorizer,
    val config: MarathonConf) extends AuthResource {

  val log = LoggerFactory.getLogger(getClass.getName)

  @GET
  @Timed
  def index(
    @PathParam("appId") appId: String,
    @Context req: HttpServletRequest): Response = authenticated(req) { implicit identity =>
    val id = appId.toRootPath
    withAuthorization(ViewRunSpec, result(groupManager.app(id)), unknownApp(id)) { _ =>
      ok(jsonObjString("versions" -> service.listAppVersions(id)))
    }
  }

  @GET
  @Timed
  @Path("{version}")
  def show(
    @PathParam("appId") appId: String,
    @PathParam("version") version: String,
    @Context req: HttpServletRequest): Response = authenticated(req) { implicit identity =>
    val id = appId.toRootPath
    val timestamp = Timestamp(version)
    withAuthorization(ViewRunSpec, service.getApp(id, timestamp), unknownApp(id, Some(timestamp))) { app =>
      ok(jsonString(app))
    }
  }
} 
开发者ID:xiaozai512,项目名称:marathon,代码行数:53,代码来源:AppVersionsResource.scala

示例9: TestService

//设置package包名称以及导入依赖的类
package info.armado.ausleihe.remote

import javax.enterprise.context.RequestScoped
import javax.transaction.Transactional
import javax.ws.rs.core.MediaType
import javax.ws.rs.{GET, Path, Produces}

import info.armado.ausleihe.model.TestInstance

@Path("/test")
@RequestScoped
class TestService {
  @GET
  @Produces(Array(MediaType.APPLICATION_JSON))
  @Path("/check")
  @Transactional
  def test(): TestInstance = {
    val result = new TestInstance()

    result.name = "Bob!"
    result.attribute = 7

    result
  }
} 
开发者ID:Spielekreis-Darmstadt,项目名称:lending,代码行数:26,代码来源:TestService.scala

示例10: ReturnGames

//设置package包名称以及导入依赖的类
package info.armado.ausleihe.remote

import javax.enterprise.context.RequestScoped
import javax.inject.Inject
import javax.transaction.Transactional
import javax.ws.rs._
import javax.ws.rs.core.MediaType

import info.armado.ausleihe.database.access.{GamesDao, LendGameDao}
import info.armado.ausleihe.database.barcode._
import info.armado.ausleihe.database.entities.{Game, LendGame}
import info.armado.ausleihe.remote.dataobjects.inuse.NotInUse
import info.armado.ausleihe.remote.requests.ReturnGameRequest
import info.armado.ausleihe.remote.results._
import info.armado.ausleihe.util.DOExtensions.{GameExtension, LendGameExtension, barcodeToString}

@Path("/return")
@RequestScoped
class ReturnGames {
  @Inject var gamesDao: GamesDao = _
  @Inject var lendGameDao: LendGameDao = _

  def findGame(gameBarcode: Barcode): Option[Either[LendGame, Game]] =
    lendGameDao.selectLendGameByGameBarcode(gameBarcode) match {
      case Some(lendGame) => Some(Left(lendGame))
      case None => gamesDao.selectActivatedByBarcode(gameBarcode) match {
        case Some(game) => Some(Right(game))
        case None => None
      }
    }

  @POST
  @Consumes(Array(MediaType.APPLICATION_XML))
  @Produces(Array(MediaType.APPLICATION_XML))
  @Path("/games")
  @Transactional
  def returnGame(returnGameRequest: ReturnGameRequest): AbstractResult = returnGameRequest match {
    case ReturnGameRequest(Some(gameBarcode)) => ValidateBarcode(gameBarcode) match {
      // the given barcode is a valid barcode
      case ValidBarcode(gameBarcode) => findGame(gameBarcode) match {
        // the game is currently borrowed by someone
        case Some(Left(lendGame)) => {
          lendGameDao.returnGame(lendGame)
          ReturnGameSuccess(lendGame.toGameData)
        }

        // the game is currently not borrowed
        case Some(Right(game)) => LendingEntityInUse(game.toGameData, NotInUse())

        // a game with the given barcode doesn't exist
        case None => LendingEntityNotExists(gameBarcode)
      }

      case InvalidBarcode(gameBarcode) => IncorrectBarcode(gameBarcode)
    }

    // wrong input
    case _ => throw new BadRequestException()
  }
} 
开发者ID:Spielekreis-Darmstadt,项目名称:lending,代码行数:61,代码来源:ReturnGames.scala

示例11: InsReq

//设置package包名称以及导入依赖的类
package org.cddb.server.http.serve

import javax.ws.rs._
import javax.ws.rs.container.{AsyncResponse, Suspended}
import javax.ws.rs.core.MediaType

import akka.actor.ActorRef
import io.circe.generic.semiauto._
import io.circe.{Decoder, Encoder}
import org.cddb.store.{InsertRequest, RetrieveRequest}

case class InsReq(key: String, value: String)

@Path("/api/storage")
@Produces(Array(MediaType.APPLICATION_JSON))
class StorageResource(receiver: ActorRef) {

  import io.circe._
  import io.circe.generic.auto._

  @GET
  @Path("/{key}")
  def tryFind(@PathParam("key") key: String, @Suspended response: AsyncResponse): Unit = {
    receiver ! RetrieveRequest(key, response)
  }

  @POST
  def tryInsert(request: String, @Suspended response: AsyncResponse): Unit = {
    val decodeClipsParam = Decoder[InsReq]
    val insReq = io.circe.parser.decode(request)(decodeClipsParam).right.get
    receiver ! InsertRequest(insReq.key, insReq.value, response)
  }
}


object StorageResource {
  implicit val fooDecoder: Decoder[InsReq] = deriveDecoder[InsReq]
  implicit val fooEncoder: Encoder[InsReq] = deriveEncoder[InsReq]
} 
开发者ID:tierex,项目名称:cddb,代码行数:40,代码来源:StorageResource.scala

示例12: DeputadosResource

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

import javax.ws.rs.container.{AsyncResponse, Suspended}
import javax.ws.rs._
import javax.ws.rs.core.MediaType

import com.codahale.metrics.annotation.{ExceptionMetered, Timed}
import com.nakamura.camara.deputados.deputado.Deputado
import org.json4s.Extraction
import org.json4s.jackson.JsonMethods._
import scala.concurrent.{ExecutionContext, Future}
import scala.util.{Failure, Success}


@Path("/deputados/")
class DeputadosResource(service: DeputadosService,
                        implicit val executionContext: ExecutionContext) {
  implicit val formats = org.json4s.DefaultFormats
  @GET
  @Timed
  @ExceptionMetered
  @Path("/fetch")
  @Produces(Array(MediaType.APPLICATION_JSON))
  def fetchDeputados(@Suspended asyncResponse: AsyncResponse): Unit = {
    val future: Future[Seq[Deputado]] = service.getDeputados() match {
      case Success(deputados) => Future(deputados)
      case Failure(err) => Future(throw new Error("Failed."))
    }
    future onSuccess { case response: Seq[Deputado] =>
      asyncResponse.resume(compact(render(Extraction.decompose(response))))
    }
    future onFailure { case t: Throwable =>
      asyncResponse.resume(t)
    }
  }
} 
开发者ID:akionakamura,项目名称:camara,代码行数:37,代码来源:DeputadosResource.scala

示例13: lookupHex

//设置package包名称以及导入依赖的类
// Copyright (C) 2016 Grier Forensics. All Rights Reserved.
package com.grierforensics.danesmimeatoolset.rest

import java.security.cert.X509Certificate
import javax.ws.rs._
import javax.ws.rs.core.{MediaType, Response}

import com.grierforensics.danesmimeatoolset.service.{BadCertificateException, Context, GensonConfig}
import org.bouncycastle.cert.dane.DANEEntry
import org.bouncycastle.util.encoders.{DecoderException, Hex}


  @GET
  @Path("{email}/hex/{index}")
  def lookupHex(@PathParam("email") email: String, @PathParam("index") index: Int): String = {
    val result = lookupHex(email) match {
      case results if results.isDefinedAt(index) => results(index)
      case otherwise => throw new WebApplicationException(Response.status(404).entity("DANE not found for email address").build())
    }
    GensonConfig.genson.serialize(result)
  }

  // // // lookupDnsZoneLine

  @GET
  @Path("{email}/dnsZoneLine")
  def lookupDnsZoneLine(@PathParam("email") email: String): Seq[String] = {
    daneSmimeaService.fetchDaneEntries(email).map(daneSmimeaService.getDnsZoneLineForDaneEntry(_)) match {
      case Nil => throw new WebApplicationException(Response.status(404).build())
      case nonempty => nonempty
    }
  }

  @GET
  @Path("{email}/dnsZoneLine/{index}")
  def lookupDnsZoneLine(@PathParam("email") email: String, @PathParam("index") index: Int): String = {
    val result = lookupDnsZoneLine(email) match {
      case results if results.isDefinedAt(index) => results(index)
      case otherwise => throw new WebApplicationException(Response.status(404).entity("DANE not found for email address").build())
    }
    GensonConfig.genson.serialize(result)
  }

  // // // createDnsZoneLineAsText

  @POST
  @Path("{email}/dnsZoneLineForCert")
  @Consumes(Array(MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN))
  def createDnsZoneLineAsText(@PathParam("email") email: String, certPem: String): String = {
    try {
      val cert: X509Certificate = daneSmimeaService.fromPem(certPem)
      val de2: DANEEntry = daneSmimeaService.createDANEEntry(email, cert)
      val result = daneSmimeaService.getDnsZoneLineForDaneEntry(de2)
      GensonConfig.genson.serialize(result)
    }
    catch {
      case [email protected](_: BadCertificateException | _: DecoderException) => throw new WebApplicationException(Response.status(400).entity(e.getMessage).build())
    }
  }
} 
开发者ID:grierforensics,项目名称:Great-DANE-Toolset,代码行数:61,代码来源:ToolsetResource.scala

示例14: IllegalArgumentExceptionMapper

//设置package包名称以及导入依赖的类
package pl.scalare.main.exceptionmapper

import javax.ws.rs.core.Response.Status
import javax.ws.rs.core.{MediaType, Response}
import javax.ws.rs.ext.ExceptionMapper

import com.codahale.metrics.{Meter, MetricRegistry}
import io.dropwizard.jersey.errors.ErrorMessage

class IllegalArgumentExceptionMapper(val exceptions: Meter) extends ExceptionMapper[IllegalArgumentException] {

  def this(metrics: MetricRegistry) = this(metrics.meter(getClass() + "exceptions"))

  override def toResponse(exception: IllegalArgumentException): Response = {
    exceptions.mark();
    return Response.status(Status.BAD_REQUEST)
      .header("X-YOU-SILLY", "true")
      .`type`(MediaType.APPLICATION_JSON_TYPE)
      .entity(new ErrorMessage(Status.BAD_REQUEST.getStatusCode(),
        "You passed an illegal argument!"))
      .build();
  }
} 
开发者ID:writeonly,项目名称:scalare,代码行数:24,代码来源:IllegalArgumentExceptionMapper.scala

示例15: HealthCheckResource

//设置package包名称以及导入依赖的类
package pl.scalare.rest.resources

import javax.inject.Inject
import javax.ws.rs.{GET, Path, Produces}
import javax.ws.rs.core.MediaType

import com.codahale.metrics.annotation.Timed
import pl.scalare.core.repo.HealthCheckRepo
import pl.scalare.rest.ViewConfiguration
import pl.scalare.rest.views.{HealthCheckView}
import org.javatuples.Pair

@Path("/hcs")
@Produces(Array(MediaType.APPLICATION_JSON, MediaType.TEXT_HTML))
class HealthCheckResource @Inject()(@Inject val repo: HealthCheckRepo, @Inject val view: ViewConfiguration) {
  @GET
  @Path("/")
  @Timed
  def checks = repo.runHealthCheckList.map(t => new Pair(t._1, t._2)).toArray


  @GET
  @Path("/view")
  @Timed
  def checksView = new HealthCheckView(view, checks)
} 
开发者ID:writeonly,项目名称:scalare,代码行数:27,代码来源:HealthCheckResource.scala


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