Skip to content

Commit

Permalink
Remove admin routes from mydevice routes
Browse files Browse the repository at this point in the history
  • Loading branch information
simao committed Mar 13, 2017
1 parent 7e2e5a0 commit e8bdcbd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ObjectResource(namespace: Directive1[Namespace], objectStore: ObjectStore,
usageHandler ! UpdateBandwidth(namespace, usageBytes, objectId)
}

val route = namespace { ns =>
val deviceRoutes = namespace { ns =>
path("objects" / PrefixedObjectId) { objectId =>
head {
val f = objectStore.exists(ns, objectId).map {
Expand Down Expand Up @@ -60,4 +60,16 @@ class ObjectResource(namespace: Directive1[Namespace], objectStore: ObjectStore,
}
}
}

val adminRoutes =
path("objects" / PrefixedObjectId) { objectId =>
namespace { ns =>
(post & hintNamespaceStorage(ns)) {
fileUpload("file") { case (_, content) =>
val f = objectStore.store(ns, objectId, content).map(_ => StatusCodes.OK)
complete(f)
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,30 @@ class TreeHubRoutes(tokenValidator: Directive0,

import Directives._

def allRoutes(nsExtract: Directive1[Namespace], coreClient: Core): Route = {
def deviceRoutes(nsExtract: Directive1[Namespace], coreClient: Core): Route = {
new ConfResource().route ~
new ObjectResource(nsExtract, objectStore, usageHandler).route ~
new ObjectResource(nsExtract, objectStore, usageHandler).deviceRoutes ~
new RefResource(nsExtract, coreClient, objectStore).route
}

def allRoutes(nsExtract: Directive1[Namespace], coreClient: Core): Route = {
deviceRoutes(nsExtract, coreClient) ~
new ObjectResource(nsExtract, objectStore, usageHandler).adminRoutes
}

val routes: Route =
handleRejections(rejectionHandler) {
ErrorHandler.handleErrors {
(pathPrefix("api" / "v2") & tokenValidator) {
allRoutes(namespaceExtractor, coreHttpClient) ~
pathPrefix("mydevice") {
allRoutes(deviceNamespace, coreHttpClient)
deviceRoutes(deviceNamespace, coreHttpClient)
}
} ~
(pathPrefix("api" / "v3") & tokenValidator) {
allRoutes(namespaceExtractor, coreBusClient)
} ~ new HealthResource(db, versionMap).route
} ~
new HealthResource(db, versionMap).route
}
}
}

2 comments on commit e8bdcbd

@atsjenkins
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TeamCity OTA+ :: treehub :: treehub ci Build 244 is now running

@atsjenkins
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TeamCity OTA+ :: treehub :: treehub ci Build 244 outcome was SUCCESS
Summary: Tests passed: 19 Build time: 00:01:22

Please sign in to comment.