Skip to content

Commit

Permalink
Add /retort/random/opener endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Brown committed Jul 13, 2016
1 parent 543d318 commit 9f39411
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
6 changes: 6 additions & 0 deletions app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,9 @@ class Retort < ActiveRecord::Base; end

Retort.where(stimulus: params[:stimulus]).sample.to_json
end

get "/retort/random/opening" do
content_tyoe :json

Retort.where(stimulus: nil).sample.to_json
end
2 changes: 1 addition & 1 deletion scrapers/tumblr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def parse_ngram channel, text
request = Net::HTTP::Get.new(uri.request_uri)
response = http.request(request)
rescue
puts "Error making request to Retort for #{user}: #{text}"
puts "Error making request to Retort for blog #{channel}: #{text}"
end

def sanitize message
Expand Down
12 changes: 12 additions & 0 deletions views/apidocs.erb
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,18 @@
</td>
<td>JSON</td>
</tr>
<tr>
<td>
<a href="/retort/random">
/retort/random/opening
</a>
</td>
<td>Fetch a random opening message</td>
<td>GET</td>
<td>
</td>
<td>JSON</td>
</tr>
</table>
</div>

Expand Down

0 comments on commit 9f39411

Please sign in to comment.