Created
July 6, 2017 09:37
-
-
Save moznion/1495622ee883ac69ff82799ece0f401a to your computer and use it in GitHub Desktop.
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
use v6.c; | |
use Crust::Request; | |
use JSON::Fast; | |
sub app($env) { | |
my $req = Crust::Request.new($env); | |
given $req.path-info { | |
when '/' { | |
my $q = $req.query-parameters<q>; | |
if (!$q) { | |
return 400, [], ["Missing mandatory parameter `q`"]; | |
} | |
return 200, ['Content-Type' => 'application/json'], [to-json { echo => $q }]; | |
} | |
default { | |
return 404, [], ["Not Found"]; | |
} | |
} | |
} |
Author
moznion
commented
Jul 6, 2017
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment