|
@@ -1,7 +1,7 @@
|
|
|
package scruffy.examples
|
|
|
|
|
|
import com.mongodb.casbah.Imports._
|
|
|
-import com.sksamuel.scruffy.EndpointProvider
|
|
|
+import com.sksamuel.scruffy.HttpEndpointProvider
|
|
|
import java.util.concurrent.ThreadLocalRandom
|
|
|
|
|
|
/** @author Stephen Samuel */
|
|
@@ -17,8 +17,8 @@ class Test2Endpoint() extends HttpEndpointProvider {
|
|
|
//for ( k <- 1 to 10000 )
|
|
|
// collection.save(DBObject("_id" -> k, "id" -> k, "randomNumber" -> random.nextInt(10000).toDouble))
|
|
|
|
|
|
- get("db").json {
|
|
|
- req =>
|
|
|
+ get("db") { implicit req =>
|
|
|
+ json {
|
|
|
val id = ThreadLocalRandom.current.nextInt(10000)
|
|
|
val dbo = collection.findOne(DBObject("_id" -> id), fields)
|
|
|
val randomNumber = Math.round(dbo.get("randomNumber").toString.toFloat)
|