本文整理汇总了Scala中javax.ws.rs.Path类的典型用法代码示例。如果您正苦于以下问题:Scala Path类的具体用法?Scala Path怎么用?Scala Path使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Path类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: CalcResource
//设置package包名称以及导入依赖的类
package org.littlewings.wildflyswarm.logstash
import javax.enterprise.context.ApplicationScoped
import javax.inject.Inject
import javax.ws.rs.core.{Context, MediaType, UriInfo}
import javax.ws.rs.{GET, Path, Produces, QueryParam}
import org.jboss.logging.Logger
@Path("calc")
@ApplicationScoped
class CalcResource {
private[logstash] val logger: Logger = Logger.getLogger(getClass)
@Inject
private[logstash] var calcService: CalcService = _
@GET
@Path("add")
@Produces(Array(MediaType.TEXT_PLAIN))
def add(@QueryParam("a") a: Int, @QueryParam("b") b: Int, @Context uriInfo: UriInfo): Int = {
// logger.debugf("url = %s, parameter a = %d, b = %d", uriInfo.getRequestUri, a, b)
logger.infof("url = %s, parameter a = %d, b = %d", uriInfo.getRequestUri, a, b)
calcService.add(a, b)
}
}
开发者ID:kazuhira-r,项目名称:wildfly-swarm-scala-examples,代码行数:27,代码来源:CalcResource.scala
示例17: FrontResource
//设置package包名称以及导入依赖的类
package org.littlewings.wildflyswarm.ribbon.frontend
import java.nio.charset.StandardCharsets
import javax.ws.rs.container.{AsyncResponse, Suspended}
import javax.ws.rs.core.MediaType
import javax.ws.rs.{GET, Path, Produces, QueryParam}
import com.fasterxml.jackson.databind.ObjectMapper
import com.netflix.ribbon.Ribbon
import io.netty.buffer.ByteBufInputStream
@Path("front")
class FrontResource {
val objectMapper: ObjectMapper = new ObjectMapper
@GET
@Path("get-now")
@Produces(Array(MediaType.APPLICATION_JSON))
def get: java.util.Map[_, _] = {
val byteBuf = Ribbon.from(classOf[TimeService]).now.execute()
objectMapper.readValue(new ByteBufInputStream(byteBuf), classOf[java.util.Map[_, _]])
}
@GET
@Path("get-now-async")
@Produces(Array(MediaType.APPLICATION_JSON))
def getAsync(@Suspended asyncResponse: AsyncResponse): Unit = {
val observable = Ribbon.from(classOf[TimeService]).now.observe
observable.subscribe { byteBuf =>
val now = objectMapper.readValue(new ByteBufInputStream(byteBuf), classOf[java.util.Map[_, _]])
asyncResponse.resume(now)
}
}
@GET
@Path("message-echo")
@Produces(Array(MediaType.TEXT_PLAIN))
def messageEcho(@QueryParam("message") message: String): String = {
val byteBuf = Ribbon.from(classOf[MessageService]).echo(message).execute()
val is = new ByteBufInputStream(byteBuf)
new String(
Iterator
.continually(is.read())
.takeWhile(_ != -1)
.map(_.asInstanceOf[Byte])
.toArray,
StandardCharsets.UTF_8
)
}
}
开发者ID:kazuhira-r,项目名称:wildfly-swarm-scala-examples,代码行数:53,代码来源:FrontResource.scala
示例18: TimeResource
//设置package包名称以及导入依赖的类
package org.littlewings.wildflyswarm.ribbon.backend
import java.net.InetAddress
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
import javax.ws.rs.core.MediaType
import javax.ws.rs.{GET, Path, Produces}
import scala.collection.JavaConverters._
@Path("time")
class TimeResource {
@GET
@Path("now")
@Produces(Array(MediaType.APPLICATION_JSON))
def now: java.util.Map[String, String] =
Map("now" -> LocalDateTime.now.format(DateTimeFormatter.ISO_DATE_TIME),
"from" -> InetAddress.getLocalHost.getHostName)
.asJava
}
开发者ID:kazuhira-r,项目名称:wildfly-swarm-scala-examples,代码行数:21,代码来源:TimeResource.scala
示例19: PasswordPolicy
//设置package包名称以及导入依赖的类
import javax.ws.rs.GET
import javax.ws.rs.Path
import javax.ws.rs.QueryParam
import com.fasterxml.jackson.module.scala.DefaultScalaModule
import io.dropwizard.Application
import io.dropwizard.Configuration
import io.dropwizard.setup.Bootstrap
import io.dropwizard.setup.Environment
class PasswordPolicy {
var rule : String = _
var help : String = _
}
class PasswordValidatorConfiguration extends Configuration {
var policies : Map[String, PasswordPolicy] = _
}
@Path("/validatePassword")
class PasswordValidatorResource(policies : Map[String,PasswordPolicy]) {
@GET def validate(@QueryParam("policy") policy: String,
@QueryParam("password") password: String) : String = {
if(password.matches(policies(policy).rule))
"OK"
else
policies(policy).help
}
}
class PasswordValidatorApplication extends Application[PasswordValidatorConfiguration] {
def run(configuration: PasswordValidatorConfiguration, environment: Environment) : Unit = {
environment.jersey().register(new PasswordValidatorResource(configuration.policies))
}
override def initialize(bootstrap: Bootstrap[PasswordValidatorConfiguration]) : Unit = {
bootstrap.getObjectMapper().registerModule(new DefaultScalaModule)
}
}
object PasswordValidatorApplication {
def main(args: Array[String]) {
new PasswordValidatorApplication().run(args:_*)
}
}
开发者ID:devguerrilla,项目名称:scala-quick-starts,代码行数:48,代码来源:PasswordValidatorApplication.scala
示例20: GisHttpHeadingService
//设置package包名称以及导入依赖的类
package rest
import javax.ws.rs.Path
import akka.util.Timeout
import com.wordnik.swagger.annotations._
import entities.JsonProtocol
import persistence.entities._
import spray.http.MediaTypes._
import spray.http.StatusCodes._
import spray.httpx.SprayJsonSupport
import spray.routing._
import utils.{Configuration, PersistenceModule}
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.duration._
import scala.util.{Failure, Success}
@Api(value = "/heading", description = "Operations about headings")
abstract class GisHttpHeadingService(modules: Configuration with PersistenceModule) extends HttpService {
import JsonProtocol._
import SprayJsonSupport._
implicit val timeout = Timeout(5.seconds)
@ApiOperation(httpMethod = "GET",
value = "Returns all companies based on heading ID",
response = classOf[List[HeadingTree]])
@ApiImplicitParams(Array(
new ApiImplicitParam(name = "headingId",
required = true,
dataType = "long",
paramType = "path",
value = "ID of heading that needs to be searched by")))
@ApiResponses(Array(new ApiResponse(code = 200, message = "Ok")))
@Path("/{headingId}/companies")
def HeadingGetAllCompaniesRoute = path("heading" / IntNumber / "companies") { (headingId) =>
get {
respondWithMediaType(`application/json`) {
onComplete(modules.headingTreeDalImpl.findAllCompaniesByHeadingId(headingId)) {
case Success(companies) => complete(companies)
case Failure(ex) => complete(InternalServerError, s"An error occurred: ${ex.getMessage}")
}
}
}
}
}
开发者ID:Lex4hex,项目名称:scala-gis-api,代码行数:51,代码来源:GisHttpHeadingService.scala
注:本文中的javax.ws.rs.Path类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论