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
class CustomerAPI < Grape::API | |
version 'v1', :using => :header | |
resource :users do | |
desc "Return all users" | |
get do | |
User.all | |
end | |
desc "Return a User with a given ID" |
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
# In Rails config/routes.rb | |
mount Twitter::API => "/" |
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
class CustomerAPI < Grape::API | |
version 'v1', :using => :header | |
resource :users do | |
desc "Create a user" | |
post :create do | |
User.create!(params[:user]).to_json | |
end | |
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
class CustomerAPI < Grape::API | |
version 'v1', :using => :header | |
resource :users do | |
desc "Will Error!" | |
post :silly do | |
error("You're silly", 500) | |
end | |
desc "Smarter version of all Users" |
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
class CustomerAPI < Grape::API | |
version 'v1', :using => :header | |
rescue_from ActiveRecord::RecordInvalid do |e| | |
# Precondition Failed | |
error_response(:status => 412, :message => { :error => e.message }.to_json) | |
end | |
helpers do | |
def authenticate! |
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
public class Challenge { | |
public static void main(String[] args) throws Exception { | |
Output.write(Input.read()); | |
} | |
} |
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
output << input |
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
public class Challenge { | |
public static void Main() { | |
Output.Write(Input.Read()); | |
} | |
} |
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
<?php | |
include 'support.php'; | |
Output::Write(Input::Read()); |
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
output += input; |
OlderNewer