Commit a87e148c authored by alain's avatar alain 🐙

api path..

parent a8e568c1
......@@ -10,7 +10,7 @@ require 'rack/cors'
use Rack::Cors do
allow do
origins '*'
resource '/*', headers: :any, methods: :get
resource '/api/*', headers: :any, methods: :get
end
end
......@@ -18,7 +18,7 @@ end
$base_url = "https://api-samenmeten.rivm.nl/v1.0"
$redis = Redis.new({:host => 'localhost', :port => 6379, :db => 2})
get '/version' do
get '/api/version' do
'v0.1'
end
......@@ -28,7 +28,7 @@ end
# 1. alle observations per station / sensor (a'la getHourlyValuesSensor)
get '/sensor/:type' do
get '/api/sensor/:type' do
type = params[:type]
uri = "#{$base_url}/Things?$filter=properties/project eq 'Hollandse Luchten'&$expand=Datastreams/Observations($orderby=phenomenonTime desc;$select=phenomenonTime,result;$top=1)"
if type != "all"
......@@ -37,7 +37,7 @@ get '/sensor/:type' do
end
body = nil
if($redis.exists uri )
if($redis.exists uri)
body = $redis.get uri
puts "cache hit"
else
......@@ -65,12 +65,12 @@ get '/sensor/:type' do
end
# json download
get '/sensor/:id/:type' do
get '/api/sensor/:id/:type' do
retrieveSensorData(params)
end
# csv download
get '/sensor/:id/:type/csv' do
get '/api/sensor/:id/:type/csv' do
json = retrieveSensorData(params)
data = JSON.parse(json)
......
......@@ -123,6 +123,6 @@ export default {
download: function(id, parameter, start, end) {
return `${host}/api/sensor/${pad(id, 3)}/${parameter}/csv?start=${start}&end=${end}`
return `${host}/sensor/${pad(id, 3)}/${parameter}/csv?start=${start}&end=${end}`
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment