Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
38 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class API::V1::ApiController < ApplicationController | ||
respond_to :json, :xml | ||
|
||
# The stats API only requires an api_key for the given app. | ||
skip_before_filter :authenticate_user! | ||
before_filter :require_api_key_or_authenticate_user! | ||
|
||
protected | ||
|
||
def require_api_key_or_authenticate_user! | ||
if params[:api_key].present? | ||
if @app = App.where(:api_key => params[:api_key]).first | ||
return true | ||
end | ||
end | ||
|
||
authenticate_user! | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class API::V1::AppsController < API::V1::ApiController | ||
def index | ||
@apps = App.all | ||
end | ||
|
||
def show | ||
@app = App.find(params[:id]) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
json.apps @apps, :id, :name, :github_repo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
json.(@app, :id, :name) | ||
json.errors @app.problems do |json, problem| | ||
json.(problem, :message, :last_noticed_at, :notices_count) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,4 @@ | ||
# Be sure to restart your server when you modify this file. | ||
|
||
# Add new inflection rules using the following format | ||
# (all these examples are active by default): | ||
# ActiveSupport::Inflector.inflections do |inflect| | ||
# inflect.plural /^(ox)$/i, '\1en' | ||
# inflect.singular /^(ox)en/i, '\1' | ||
# inflect.irregular 'person', 'people' | ||
# inflect.uncountable %w( fish sheep ) | ||
# end | ||
ActiveSupport::Inflector.inflections do |inflect| | ||
inflect.acronym 'API' | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters