This is an in-progress branch with a spray based api service that talks to the orient graph to address #52
At the moment, you can run sbt 'project api_server' 'run-main io.mediachain.api.Boot' to listen on localhost:8888.
There's only two functional routes so far:
/canonicals - list all canonicals in the system in pages of 20. accepts a page int param that defaults to zero. Pagination is implemented with gremlin's range function.
/canonicals/some-canonical-id - retrieve a single canonical by uuid. Returns a 404 if no canonical exists with that id.
These return JSON objects using the default json4s serializer (or an array of objects for the list endpoint). The id field is currently incorrectly serialized as an empty object. I think we can add a serializer for ORecordId to the DefaultFormats to convert it to a string without too much fuss.
The route structure is defined in the LSpaceService trait. At the moment the methods that actually traverse the graph are defined in the same file, but we should move them as we start building out a bigger api.
We should discuss whether we want to continue using spray/akka in the long term, I kind of share some of vyzo's concerns. Let's hold off on this merge for the moment
This is an in-progress branch with a spray based api service that talks to the orient graph to address #52
At the moment, you can run
sbt 'project api_server' 'run-main io.mediachain.api.Boot'
to listen onlocalhost:8888
.There's only two functional routes so far:
/canonicals
- list all canonicals in the system in pages of 20. accepts apage
int param that defaults to zero. Pagination is implemented with gremlin'srange
function./canonicals/some-canonical-id
- retrieve a single canonical by uuid. Returns a 404 if no canonical exists with that id.These return JSON objects using the default json4s serializer (or an array of objects for the list endpoint). The
id
field is currently incorrectly serialized as an empty object. I think we can add a serializer forORecordId
to theDefaultFormats
to convert it to a string without too much fuss.The biggest missing piece here is the concurrency model; the routes should probably be returning
Future
s instead of performing blocking db calls directly. This looks relevant: http://spray.io/documentation/1.2.3/spray-routing/future-directives/The route structure is defined in the
LSpaceService
trait. At the moment the methods that actually traverse the graph are defined in the same file, but we should move them as we start building out a bigger api.