Advertisement
Guest User

Untitled

a guest
May 1st, 2015
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 1.51 KB | None | 0 0
  1. /**
  2.  * Spray HTTP listener for all ACL related requests
  3.  */
  4. trait ACLSprayService
  5. {
  6.     this: CommonSprayService ⇒
  7.  
  8.  
  9.   val aclRoute =
  10.     pathPrefix(AuthPath) {
  11.       (pathEnd & post) {
  12.         tracedHandleRest[AuthRequest, AuthResponse]
  13.       } ~
  14.       (pathEnd & delete) {
  15.         tracedHandleRest[LogoutRequest, SuccessResponse.Ok.type]
  16.       } ~
  17.         (path(Segment) & post) { tokenId ⇒
  18.           tracedHandleWith(tokenId :: HNil) {
  19.             restProcess[AuthByTokenRequest, AuthResponse]
  20.           }
  21.         }
  22.     } ~
  23.         (path(InvitationsPath / Segment / InvitationsAcceptPath) & post) { invitationId ⇒
  24.             tracedHandleWith(invitationId :: HNil) {
  25.                 restProcess[AcceptInvitationRequest, AuthResponse]
  26.             }
  27.         } ~
  28.         (path(CredentialsPath / CredentialsResetPath) & post) {
  29.             tracedHandleRest[ResetPasswordRequest, NewTokenResponse]
  30.         } ~
  31.         path(AccountsPath / CommonConfig.CVD.RootAccountToken) {
  32.             tracedHandleRest[CreateRootAccountRequest, SuccessResponse.Created.type]
  33.         } ~
  34.         pathPrefix(AccountsPath) {
  35.             pathPrefix(BSONObjectIDSegment) {
  36.                 accountId =>
  37.                     pathPrefix(CredentialsPath) {
  38.                         pathEnd {
  39.                             put {
  40.                                 tracedHandleWith(accountId :: HNil) {
  41.                                     restProcess[SetPasswordRequest, SuccessResponse.Ok.type]
  42.                                 }
  43.                             }
  44.                         } ~
  45.                         (path(CredentialsResetPath) & post) {
  46.                             tracedHandleWith(accountId :: HNil) {
  47.                                 restProcess[AdminResetPasswordRequest, NewTokenResponse]
  48.                             }
  49.                         }
  50.                     }
  51.             }
  52.         }
  53.  
  54.     registerApiRoute(aclRoute)
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement