Merge pull request #1189 from kormoc/support_jsonp_in_api
Support JSONP callbacks for the API/v1 endpoints
This commit is contained in:
commit
7cc2609662
5 changed files with 22 additions and 7 deletions
|
|
@ -4,12 +4,15 @@ module Api
|
|||
load_resource find_by: :short_title
|
||||
respond_to :json
|
||||
|
||||
# Disable forgery protection for any json requests. This is required for jsonp support
|
||||
skip_before_action :verify_authenticity_token
|
||||
|
||||
def index
|
||||
render json: @conferences, serializer: ConferencesArraySerializer
|
||||
render json: @conferences, serializer: ConferencesArraySerializer, callback: params['callback']
|
||||
end
|
||||
|
||||
def show
|
||||
render json: [@conference], serializer: ConferencesArraySerializer
|
||||
render json: [@conference], serializer: ConferencesArraySerializer, callback: params['callback']
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@ module Api
|
|||
load_resource :conference, find_by: :short_title
|
||||
respond_to :json
|
||||
|
||||
# Disable forgery protection for any json requests. This is required for jsonp support
|
||||
skip_before_action :verify_authenticity_token
|
||||
|
||||
def index
|
||||
events = Event.includes(:track, :event_type, event_users: :user)
|
||||
|
||||
|
|
@ -11,7 +14,7 @@ module Api
|
|||
events = events.where(program: @conference.program)
|
||||
end
|
||||
|
||||
respond_with events.confirmed
|
||||
respond_with events.confirmed, callback: params[:callback]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,11 +4,14 @@ module Api
|
|||
load_resource :conference, find_by: :short_title
|
||||
respond_to :json
|
||||
|
||||
# Disable forgery protection for any json requests. This is required for jsonp support
|
||||
skip_before_action :verify_authenticity_token
|
||||
|
||||
def index
|
||||
if @conference
|
||||
respond_with @conference.venue ? @conference.venue.rooms : Room.none
|
||||
respond_with @conference.venue ? @conference.venue.rooms : Room.none, callback: params[:callback]
|
||||
else
|
||||
respond_with Room.all
|
||||
respond_with Room.all, callback: params[:callback]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@ module Api
|
|||
load_resource :conference, find_by: :short_title
|
||||
respond_to :json
|
||||
|
||||
# Disable forgery protection for any json requests. This is required for jsonp support
|
||||
skip_before_action :verify_authenticity_token
|
||||
|
||||
def index
|
||||
if @conference
|
||||
users = User.joins(event_users: { event: { program: :conference} })
|
||||
|
|
@ -13,7 +16,7 @@ module Api
|
|||
end
|
||||
|
||||
users = users.where(event_users: {event_role: :speaker}).uniq
|
||||
render json: users, each_serializer: SpeakerSerializer
|
||||
render json: users, each_serializer: SpeakerSerializer, callback: params['callback']
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,10 +4,13 @@ module Api
|
|||
load_resource :conference, find_by: :short_title
|
||||
respond_to :json
|
||||
|
||||
# Disable forgery protection for any json requests. This is required for jsonp support
|
||||
skip_before_action :verify_authenticity_token
|
||||
|
||||
def index
|
||||
tracks = @conference ? @conference.program.tracks : Track.all
|
||||
|
||||
respond_with tracks
|
||||
respond_with tracks, callback: params[:callback]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue