Creating a simpler API endpoint for embedded parsing
This commit is contained in:
parent
6957ab7ac1
commit
04d9b0bf68
|
@ -1,8 +1,8 @@
|
||||||
class SpaceApiController < ApplicationController
|
class SpaceApiController < ApplicationController
|
||||||
# Individually remove authorizing stuff since there is no SpaceApi model
|
# Individually remove authorizing stuff since there is no SpaceApi model
|
||||||
authorize_resource :except => [:index, :access, :access_post, :alert_if_not_status]
|
authorize_resource :except => [:index, :simple, :access, :access_post, :alert_if_not_status]
|
||||||
# User auth here happens via params, instead of form.
|
# User auth here happens via params, instead of form.
|
||||||
before_filter :authenticate_user!, :except => [:index, :access, :access_post, :alert_if_not_status]
|
before_filter :authenticate_user!, :except => [:index, :simple, :access, :access_post, :alert_if_not_status]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@json = JSON.parse(Setting.space_api_json_template)
|
@json = JSON.parse(Setting.space_api_json_template)
|
||||||
|
@ -29,6 +29,11 @@ class SpaceApiController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def simple
|
||||||
|
door_status = DoorLog.show_status # Expect {:unlocked => boolean, :door_1_locked => boolean, :door_2_locked => boolean}
|
||||||
|
render :json => door_status
|
||||||
|
end
|
||||||
|
|
||||||
def access
|
def access
|
||||||
@status = DoorLog.show_status
|
@status = DoorLog.show_status
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,7 @@ Dooraccess::Application.routes.draw do
|
||||||
match 'cards/:id/upload' => 'cards#upload', :as => :upload
|
match 'cards/:id/upload' => 'cards#upload', :as => :upload
|
||||||
|
|
||||||
match 'space_api' => 'space_api#index', :as => :space_api
|
match 'space_api' => 'space_api#index', :as => :space_api
|
||||||
|
match 'space_api/simple(.format)' => 'space_api#simple', :as => :space_api_simple
|
||||||
match 'space_api/alert_if_not/:status' => 'space_api#alert_if_not_status', :via => :get, :as => :space_api_alert_if_not_status
|
match 'space_api/alert_if_not/:status' => 'space_api#alert_if_not_status', :via => :get, :as => :space_api_alert_if_not_status
|
||||||
match 'space_api/access' => 'space_api#access', :via => :get, :as => :space_api_access
|
match 'space_api/access' => 'space_api#access', :via => :get, :as => :space_api_access
|
||||||
match 'space_api/access' => 'space_api#access_post', :via => :post
|
match 'space_api/access' => 'space_api#access_post', :via => :post
|
||||||
|
|
Loading…
Reference in New Issue
Block a user