summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2017-12-06 07:52:32 +0100
committerYorhel <git@yorhel.nl>2017-12-06 07:52:32 +0100
commit5e4f2dfdb72cde9d17ae33cba3a55c81937f4d80 (patch)
treed3372ad3ab73bfd948597719e31ec1a17d8ea644 /examples
parent0f0531740d8af1cd343f5fa0e2f3906cac72271c (diff)
Add reqJSON and resJSON for simple JSON API support
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/singlefile.pl8
1 files changed, 8 insertions, 0 deletions
diff --git a/examples/singlefile.pl b/examples/singlefile.pl
index 272a9d6..6544ce1 100755
--- a/examples/singlefile.pl
+++ b/examples/singlefile.pl
@@ -32,6 +32,8 @@ TUWF::register(
# /sub/ as the second argument to subpage().
qr/sub\/(.*)/ => \&subpage,
+ qr{api/echo\.json} => \&echoapi,
+
# all requests for non-registered URIs will throw a 404
);
@@ -70,3 +72,9 @@ sub subpage {
}
+sub echoapi {
+ my $self = shift;
+ $self->resJSON($self->reqJSON);
+}
+
+