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


Scala Path类代码示例

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


在下文中一共展示了Path类的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: RecordHistoryService

//设置package包名称以及导入依赖的类
package au.csiro.data61.magda.registry

import akka.actor.ActorSystem
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport
import akka.http.scaladsl.model.StatusCodes
import akka.http.scaladsl.server.Directives._
import akka.stream.Materializer
import akka.stream.scaladsl.Sink
import au.csiro.data61.magda.model.Registry._
import io.swagger.annotations._
import javax.ws.rs.Path
import scala.concurrent.Await
import scala.concurrent.duration._
import scalikejdbc.DB

@Path("/records/{recordId}/history")
@io.swagger.annotations.Api(value = "record history", produces = "application/json")
class RecordHistoryService(system: ActorSystem, materializer: Materializer) extends Protocols with SprayJsonSupport {
  @ApiOperation(value = "Get a list of all events affecting this record", nickname = "history", httpMethod = "GET", response = classOf[EventsPage])
  @ApiImplicitParams(Array(
    new ApiImplicitParam(name = "recordId", required = true, dataType = "string", paramType = "path", value = "ID of the record for which to fetch history.")
  ))
  def history = get { path(Segment / "history") { id => { parameters('pageToken.as[Long].?, 'start.as[Int].?, 'limit.as[Int].?) { (pageToken, start, limit) =>
    complete {
      DB readOnly { session =>
        EventPersistence.getEvents(session, recordId = Some(id), pageToken = pageToken, start = start, limit = limit)
      }
    }
  } } } }

  @Path("/{eventId}")
  @ApiOperation(value = "Get the version of a record that existed after a given event was applied", nickname = "version", httpMethod = "GET", response = classOf[Record])
  @ApiImplicitParams(Array(
    new ApiImplicitParam(name = "recordId", required = true, dataType = "string", paramType = "path", value = "ID of the record to fetch."),
    new ApiImplicitParam(name = "eventId", required = true, dataType = "string", paramType = "path", value = "The ID of the last event to be applied to the record.  The event with this ID need not actually apply to the record, in which case that last event prior to this even that does apply will be used.")
  ))
  @ApiResponses(Array(
    new ApiResponse(code = 404, message = "No record exists with the given ID, it does not have a CreateRecord event, or it has been deleted.", response = classOf[BadRequest])
  ))
  def version = get { path(Segment / "history" / Segment) { (id, version) => { parameters('aspect.*, 'optionalAspect.*) { (aspects: Iterable[String], optionalAspects: Iterable[String]) =>
    DB readOnly { session =>
      val events = EventPersistence.streamEventsUpTo(version.toLong, recordId = Some(id))
      val recordSource = RecordPersistence.reconstructRecordFromEvents(id, events, aspects, optionalAspects)
      val sink = Sink.head[Option[Record]]
      val future = recordSource.runWith(sink)(materializer)
      Await.result[Option[Record]](future, 5 seconds) match {
        case Some(record) => complete(record)
        case None => complete(StatusCodes.NotFound, BadRequest("No record exists with that ID, it does not have a CreateRecord event, or it has been deleted."))
      }
    }
  } } } }

  val route =
    history ~
    version
} 
开发者ID:TerriaJS,项目名称:magda,代码行数:57,代码来源:RecordHistoryService.scala

示例3: LeaderResource

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

import javax.servlet.http.HttpServletRequest
import javax.ws.rs.core.{ Context, Response }
import javax.ws.rs.{ DELETE, GET, Path, Produces }

import com.google.inject.Inject
import mesosphere.chaos.http.HttpConf
import mesosphere.marathon.MarathonConf
import mesosphere.marathon.api.{ AuthResource, MarathonMediaType, RestResource }
import mesosphere.marathon.core.election.ElectionService
import mesosphere.marathon.plugin.auth._

@Path("v2/leader")
class LeaderResource @Inject() (
  electionService: ElectionService,
  val config: MarathonConf with HttpConf,
  val authenticator: Authenticator,
  val authorizer: Authorizer)
    extends RestResource with AuthResource {

  @GET
  @Produces(Array(MarathonMediaType.PREFERRED_APPLICATION_JSON))
  def index(@Context req: HttpServletRequest): Response = authenticated(req) { implicit identity =>
    withAuthorization(ViewResource, AuthorizedResource.Leader) {
      electionService.leaderHostPort match {
        case None => notFound("There is no leader")
        case Some(leader) =>
          ok(jsonObjString("leader" -> leader))
      }
    }
  }

  @DELETE
  @Produces(Array(MarathonMediaType.PREFERRED_APPLICATION_JSON))
  def delete(@Context req: HttpServletRequest): Response = authenticated(req) { implicit identity =>
    withAuthorization(UpdateResource, AuthorizedResource.Leader) {
      if (electionService.isLeader) {
        electionService.abdicateLeadership()
        ok(jsonObjString("message" -> "Leadership abdicated"))
      } else {
        notFound("There is no leader")
      }
    }
  }
} 
开发者ID:xiaozai512,项目名称:marathon,代码行数:47,代码来源:LeaderResource.scala

示例4: 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

示例5: AliasBroadcastApiRoute

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

import javax.ws.rs.Path

import akka.http.scaladsl.server.Route
import com.wavesplatform.UtxPool
import com.wavesplatform.settings.RestAPISettings
import io.netty.channel.group.ChannelGroup
import io.swagger.annotations._
import scorex.BroadcastRoute
import scorex.api.http._

@Path("/alias/broadcast")
@Api(value = "/alias")
case class AliasBroadcastApiRoute(
    settings: RestAPISettings,
    utx: UtxPool,
    allChannels: ChannelGroup)
  extends ApiRoute with BroadcastRoute {
  override val route = pathPrefix("alias" / "broadcast") {
    signedCreate
  }

  @Path("/create")
  @ApiOperation(value = "Broadcasts a signed alias transaction",
    httpMethod = "POST",
    produces = "application/json",
    consumes = "application/json")
  @ApiImplicitParams(Array(
    new ApiImplicitParam(
      name = "body",
      value = "Json with data",
      required = true,
      paramType = "body",
      dataType = "scorex.api.http.alias.SignedCreateAliasRequest",
      defaultValue = "{\n\t\"alias\": \"aliasalias\",\n\t\"senderPublicKey\": \"11111\",\n\t\"fee\": 100000\n\t\"timestamp\": 12345678,\n\t\"signature\": \"asdasdasd\"\n}"
    )
  ))
  @ApiResponses(Array(new ApiResponse(code = 200, message = "Json with response or error")))
  def signedCreate: Route = (path("create") & post) {
    json[SignedCreateAliasRequest] { aliasReq =>
      doBroadcast(aliasReq.toTx)
    }
  }
} 
开发者ID:wavesplatform,项目名称:Waves,代码行数:46,代码来源:AliasBroadcastApiRoute.scala

示例6: PaymentApiRoute

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

import javax.ws.rs.Path

import akka.http.scaladsl.server.Route
import com.wavesplatform.UtxPool
import com.wavesplatform.settings.RestAPISettings
import io.netty.channel.group.ChannelGroup
import io.swagger.annotations._
import scorex.BroadcastRoute
import scorex.api.http.assets.TransferRequest
import scorex.transaction.TransactionFactory
import scorex.utils.Time
import scorex.wallet.Wallet

@Path("/payment")
@Api(value = "/payment")
@Deprecated
case class PaymentApiRoute(settings: RestAPISettings, wallet: Wallet, utx: UtxPool, allChannels: ChannelGroup, time: Time)
  extends ApiRoute with BroadcastRoute {

  override lazy val route = payment

  @Deprecated
  @ApiOperation(value = "Send payment. Deprecated: use /assets/transfer instead",
    notes = "Send payment to another wallet. Deprecated: use /assets/transfer instead",
    httpMethod = "POST",
    produces = "application/json",
    consumes = "application/json")
  @ApiImplicitParams(Array(
    new ApiImplicitParam(
      name = "body",
      value = "Json with data",
      required = true,
      paramType = "body",
      dataType = "scorex.api.http.assets.PaymentRequest",
      defaultValue = "{\n\t\"amount\":400,\n\t\"fee\":1,\n\t\"sender\":\"senderId\",\n\t\"recipient\":\"recipientId\"\n}"
    )
  ))
  @ApiResponses(Array(
    new ApiResponse(code = 200, message = "Json with response or error")
  ))
  def payment: Route = (path("payment") & post & withAuth) {
    json[TransferRequest] { p =>
      doBroadcast(TransactionFactory.transferAsset(p, wallet, time))
    }
  }
} 
开发者ID:wavesplatform,项目名称:Waves,代码行数:49,代码来源:PaymentApiRoute.scala

示例7: WalletApiRoute

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

import javax.ws.rs.Path
import akka.http.scaladsl.server.Route
import com.wavesplatform.settings.RestAPISettings
import io.swagger.annotations._
import play.api.libs.json.Json
import scorex.crypto.encode.Base58
import scorex.wallet.Wallet

@Path("/wallet")
@Api(value = "/wallet")
case class WalletApiRoute(settings: RestAPISettings, wallet: Wallet) extends ApiRoute {

  override lazy val route = seed

  @Path("/seed")
  @ApiOperation(value = "Seed", notes = "Export wallet seed", httpMethod = "GET")
  def seed: Route = (path("wallet" / "seed") & get & withAuth) {
    complete(Json.obj("seed" -> Base58.encode(wallet.seed)))
  }
} 
开发者ID:wavesplatform,项目名称:Waves,代码行数:23,代码来源:WalletApiRoute.scala

示例8: NodeApiRoute

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

import javax.ws.rs.Path

import akka.http.scaladsl.server.Route
import com.wavesplatform.Shutdownable
import com.wavesplatform.settings.{Constants, RestAPISettings}
import io.swagger.annotations._
import play.api.libs.json.Json
import scorex.api.http.{ApiRoute, CommonApiFunctions}
import scorex.utils.ScorexLogging

@Path("/node")
@Api(value = "node")
case class NodeApiRoute(settings: RestAPISettings, application: Shutdownable)
  extends ApiRoute with CommonApiFunctions with ScorexLogging {

  override lazy val route = pathPrefix("node") {
    stop ~ status ~ version
  }

  @Path("/version")
  @ApiOperation(value = "Version", notes = "Get Waves node version", httpMethod = "GET")
  @ApiResponses(Array(
    new ApiResponse(code = 200, message = "Json Waves node version")
  ))
  def version: Route = (get & path("version")) {
    complete(Json.obj("version" -> Constants.AgentName))
  }

  @Path("/stop")
  @ApiOperation(value = "Stop", notes = "Stop the node", httpMethod = "POST")
  def stop: Route = (post & path("stop") & withAuth) {
    log.info("Request to stop application")
    application.shutdown()
    complete(Json.obj("stopped" -> true))
  }

  @Path("/status")
  @ApiOperation(value = "Status", notes = "Get status of the running core", httpMethod = "GET")
  def status: Route = (get & path("status")) {
    complete(Json.obj())
  }
} 
开发者ID:wavesplatform,项目名称:Waves,代码行数:45,代码来源:NodeApiRoute.scala

示例9: 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

示例10: TaskResource

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

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

import com.codahale.metrics.annotation.Timed
import pl.scalare.core.repo.TaskRepo
import pl.scalare.rest.ViewConfiguration
import pl.scalare.rest.views.TasksView

@Path("/tasks")
@Produces(Array(MediaType.APPLICATION_JSON, MediaType.TEXT_HTML))
class TaskResource @Inject()(@Inject val repo: TaskRepo, @Inject val view: ViewConfiguration) {

  @GET
  @Path("/")
  @Timed
  def tasks = repo.tasks.toArray

  @GET
  @Path("/view")
  @Timed
  def tasksView = new TasksView(view, tasks)
} 
开发者ID:writeonly,项目名称:scalare,代码行数:26,代码来源:TaskResource.scala

示例11: EventResource

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

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

import com.codahale.metrics.annotation.Timed
import pl.scalare.core.repo.EventRepo
import pl.scalare.rest.views.EventsView

@Path("/event")
@Produces(Array(MediaType.APPLICATION_JSON))
class EventResource @Inject()(@Inject val repo: EventRepo) {
  @GET()
  @Path("/view")
  @Timed
  def eventsView = new EventsView(events)

  @GET()
  @Path("/")
  @Timed
  def events = repo.getAll.toArray

} 
开发者ID:writeonly,项目名称:scalare,代码行数:25,代码来源:EventResource.scala

示例12: QuotesService

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

import javax.ws.rs.Path

import akka.http.scaladsl.server.{Directive0, Route}
import akka.http.scaladsl.server.Directives._
import io.swagger.annotations._
import models.{DistanceResult, QuoteResult}
import ch.megard.akka.http.cors.scaladsl.CorsDirectives._

import scala.concurrent.ExecutionContext.Implicits.global

@Api(value = "/quote", produces = "application/json")
@Path("/quote")
class QuotesService {
  val quotesController = QuotesControllerSingleton

  val routes: Route = {
    logRequestResult("quote-service") {
      pathPrefix("quote") {
        quoteRoute
      }
    }
  }

  @ApiOperation(httpMethod = "GET", response = classOf[DistanceResult], value = "Returns a quote")
  @ApiImplicitParams(Array(
    new ApiImplicitParam(name = "origin", value = "Origin address", required = true, dataType = "string", paramType = "query"),
    new ApiImplicitParam(name = "destination", value = "Destination address", required = true, dataType = "string", paramType = "query")
  ))
  @ApiResponses(Array(
    new ApiResponse(code = 200, message = "Returns a quote", response = classOf[QuoteResult]),
    new ApiResponse(code = 500, message = "Internal server error")
  ))
  def quoteRoute = {
    cors() {
      get {
        parameters('origin, 'destination) { (origin, destination) =>
          complete {
            quotesController.buildQuoteResponse(origin, destination)
          }
        }
      }
    }
  }
} 
开发者ID:greghxc,项目名称:shakespeare,代码行数:47,代码来源:QuoteService.scala

示例13: ProfilesService

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

import javax.ws.rs.Path

import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.server.Route
import io.swagger.annotations.{Api, _}
import models.{FuelSurchargeProfile, QuoteProfile}

@Api(value = "/profiles", produces = "application/json")
@Path("/profiles")
class ProfilesService {
  val profilesController: ProfilesController = ProfilesControllerSingleton

  val routes: Route = {
    logRequestResult("profiles-service") {
      pathPrefix("profiles") {
        quoteRoute ~ surchargeRoute
      }
    }
  }

  @Path("/quote")
  @ApiOperation(httpMethod = "GET", response = classOf[Seq[QuoteProfile]], value = "Returns active quote profiles")
  @ApiResponses(Array(
    new ApiResponse(code = 200, message = "Return active quote profiles", response = classOf[Seq[QuoteProfile]]),
    new ApiResponse(code = 500, message = "Internal server error")
  ))
  def quoteRoute = {
    pathPrefix("quote") {
      get {
        complete {
          profilesController.getQuoteProfiles()
        }
      }
    }
  }

  @Path("/surcharge")
  @ApiOperation(httpMethod = "GET", response = classOf[FuelSurchargeProfile], value = "Returns active surcharge profile")
  @ApiResponses(Array(
    new ApiResponse(code = 200, message = "Return active surcharge profile", response = classOf[FuelSurchargeProfile]),
    new ApiResponse(code = 500, message = "Internal server error")
  ))
  def surchargeRoute = {
    pathPrefix("surcharge") {
      get {
        complete {
          profilesController.getSurchargeProfile()
        }
      }
    }
  }
} 
开发者ID:greghxc,项目名称:shakespeare,代码行数:55,代码来源:ProfilesService.scala

示例14: getVersion

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

import javax.ws.rs.Path

import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.server.Route
import com.softwaremill.bootzooka.common.api.RoutesSupport
import com.softwaremill.bootzooka.version.BuildInfo._
import io.circe.generic.auto._
import io.swagger.annotations.{ApiResponse, _}

import scala.annotation.meta.field

trait VersionRoutes extends RoutesSupport with VersionRoutesAnnotations {

  implicit val versionJsonCbs = CanBeSerialized[VersionJson]

  val versionRoutes = pathPrefix("version") {
    pathEndOrSingleSlash {
      getVersion
    }
  }

  def getVersion: Route =
    complete {
      VersionJson(buildSha.substring(0, 6), buildDate)
    }
}

@Api(
  value = "Version",
  produces = "application/json", consumes = "application/json"
)
@Path("api/version")
trait VersionRoutesAnnotations {

  @ApiOperation(httpMethod = "GET", response = classOf[VersionJson], value = "Returns an object which describes running version")
  @ApiResponses(Array(
    new ApiResponse(code = 500, message = "Internal Server Error"),
    new ApiResponse(code = 200, message = "OK", response = classOf[VersionJson])
  ))
  @Path("/")
  def getVersion: Route
}

@ApiModel(description = "Short description of the version of an object")
case class VersionJson(
  @(ApiModelProperty @field)(value = "Build number") build: String,
  @(ApiModelProperty @field)(value = "The timestamp of the build") date: String
) 
开发者ID:Bii03,项目名称:students-clustering,代码行数:51,代码来源:VersionRoutes.scala

示例15: MessageResource

//设置package包名称以及导入依赖的类
package org.littlewings.wildflyswarm.hystrix

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

import org.jboss.logging.Logger

@Path("message")
class MessageResource {
  val logger: Logger = Logger.getLogger(classOf[MessageResource])

  @GET
  @Path("fail-fast")
  @Produces(Array(MediaType.TEXT_PLAIN))
  def failFast: String = {
    logger.infof("start resource")

    val command = new FailFastMessageCommand
    val message = command.execute()

    logger.infof("end resource")

    message + System.lineSeparator
  }

  @GET
  @Path("fail-silent")
  @Produces(Array(MediaType.TEXT_PLAIN))
  def failSilent: String = {
    logger.infof("start resource")

    val command = new FailSilentCommand
    val message = command.execute()

    logger.infof("end resource")

    message + System.lineSeparator
  }

  @GET
  @Path("configured")
  @Produces(Array(MediaType.TEXT_PLAIN))
  def configured: String = {
    logger.infof("start configured-message resource")

    val command = new ConfiguredMessageCommand
    val message = command.execute()

    logger.infof("end configured-message resource")

    message + System.lineSeparator
  }
} 
开发者ID:kazuhira-r,项目名称:wildfly-swarm-scala-examples,代码行数:54,代码来源:MessageResource.scala


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