This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package eu.inn.forgame.api.rest | |
import spray.routing.Route | |
import eu.inn.util.akka.ActorSystemComponent | |
import eu.inn.util.http.RestServiceComponent | |
import eu.inn.util.servicebus.ServiceBusComponent | |
import eu.inn.datamodel.forgame.auth.IssueToken | |
import eu.inn.forgame.api.directives.{AuthProviderComponent, AuthUser} | |
case class TestClass(name: String, age: Int) | |
case class TestClassNew(param: String) | |
trait TokensComponent { | |
this: ActorSystemComponent | |
with RestServiceComponent | |
with AuthProviderComponent | |
with ServiceBusComponent ⇒ | |
lazy val tokensRoutes = new RestRoutes { | |
def routes: Route = | |
auth { user: AuthUser ⇒ | |
(pathEnd & metrics("api.tokens")) { | |
rateLimit("issue-account-token", "userId" → user.id) { | |
post { | |
formField(Fields.Expiration.?) { expiration ⇒ | |
complete(serviceBus ?? IssueToken(user.id.toString, user.token, expiration)) | |
} | |
} | |
} | |
} ~ | |
post { | |
path("test") { | |
contentAs[TestClass]("application/vnd.acme.person") { tc ⇒ | |
complete("tc: " + tc) | |
} ~ | |
contentAs[TestClassNew]("application/vnd.acme.new") { tcw ⇒ | |
complete("tc new: " + tcw) | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
"/users/:id/presons/:id?" => { "vnd.acme.person" -> PersonClass, "vnd.acme.new" -> NewPersonClass }