Loading
XN Logic Corporation
This is a live streamed presentation. You will automatically follow the presenter and see the slide they're currently on.
Brought to you by
If you are building a graph-based web application, you will (most likely) a web API that exposes your graph to the world.
Let's see how to do that with Pacer and Sinatra...
$ gem install sinatra
$ gem install trinidad
$ ruby sinatra_simple_demo.rb
Run the simple demo (in the root of our repo)
Make an API call
$ curl http://localhost:4567/customers/CENTC
{"phone":"(5) 555-3392",
"companyName":"Centro comercial Moctezuma",
"customerID":"CENTC","fax":"(5) 555-7293","type":"Customer"}
require 'sinatra'
# ...
@@g = Pacer.tg # Global graph object
# ...
get '/customers/:customer_id' do
content_type :json
id = params[:customer_id]
customer = @@g.v(NorthWind::Customer, customerID: id).first
if customer
customer.properties.to_json
else
status 404
end
end
get '/customers/:customer_id/purchases' do
content_type :json
id = params[:customer_id]
products = @@g.v(NorthWind::Customer, customerID: id)
.products.uniq
if products
products.properties.to_a.to_json
else
status 404
end
end
http://localhost:4567/customers/CENTC/purchases
Allows to send GET requests to
Building a graph traversal API using
Step 1:
gem install pacer
gem install pacer-neo4j
Step 2:
gem install sinatra
gem install trinidad
Step 3:
cd pacer-northwind
ruby run_demo.rb ~/pacer-northwind-data