Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

Commit

Permalink
Force JS ContentType for Wordnik API responses (#3468)
Browse files Browse the repository at this point in the history
moollaza authored Jan 30, 2018

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent bc58f25 commit 35cd0f8
Showing 3 changed files with 3 additions and 4 deletions.
1 change: 1 addition & 0 deletions lib/DDG/Spice/RandPOS.pm
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ use Text::Trim;
spice from => '([^/]+)/?(?:([^/]+)/?(?:([^/]+)|)|)';
spice to => 'http://api.wordnik.com/v4/words.json/randomWords?includePartOfSpeech=$1&minCorpusCount=10000&limit=$2&api_key={{ENV{DDG_SPICE_WORDNIK_APIKEY}}}&callback={{callback}}';
spice proxy_cache_valid => '418 1d';
spice content_type_javascript => 1;

# List of all trigger words
my @triggerWords = map { ($_, $_."s") } qw(noun verb adjective pronoun preposition conjunction adverb);
1 change: 1 addition & 0 deletions lib/DDG/Spice/RandWord.pm
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@ use List::Util 'min';
spice from => '(?:([0-9]+)\-([0-9]+)\-([0-9]+))';
spice to => 'http://api.wordnik.com/v4/words.json/randomWords?minLength=$1&maxLength=$2&limit=$3&api_key={{ENV{DDG_SPICE_WORDNIK_APIKEY}}}&callback={{callback}}';
spice proxy_cache_valid => "418 1d";
spice content_type_javascript => 1;

triggers any => "random word", "random words";

5 changes: 1 addition & 4 deletions lib/DDG/Spice/WordOfTheDay.pm
Original file line number Diff line number Diff line change
@@ -6,10 +6,9 @@ use DDG::Spice;

spice is_cached => 1;
spice proxy_cache_valid => "200 1d";

spice wrap_jsonp_callback => 1;
spice content_type_javascript => 1;

# for testing, run: DDG_SPICE_WORDNIK_APIKEY=a2a73e7b926c924fad7001ca3111acd55af2ffabf50eb4ae5 duckpan server
spice to => 'http://api.wordnik.com/v4/words.json/wordOfTheDay?api_key={{ENV{DDG_SPICE_WORDNIK_APIKEY}}}';

triggers start =>
@@ -19,9 +18,7 @@ triggers start =>
'what is the word of the day';

handle remainder => sub {

return unless $_ eq '';

return $_;
};

0 comments on commit 35cd0f8

Please sign in to comment.