Ich verwende Mojolicious 7.20 und Strawberry Perl 5.20 32bit.
Aus irgendeinem Grund klappt es nicht unter Windows über die Kommandozeile an die Mojolicious-Lite-App JSON zu senden.
Unter Linux geht das wunderbar.
Ein Bespiel aus
http://mojolicious.org/perldoc/Mojolicious/Guides/... abgeleitet:
Die App:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use Mojolicious::Lite;
plugin 'PODRenderer';
get '/' => sub {
my $c = shift;
$c->render(template => 'index');
};
put '/reverse' => sub {
my $c = shift;
my $hash = $c->req->json;
$hash->{test} = reverse $hash->{test};
$c->render(json => $hash);
};
app->start;
__DATA__
@@ index.html.ep
% layout 'default';
% title 'Welcome';
<h1>Welcome to the Mojolicious real-time web framework!</h1>
To learn more, you can browse through the documentation
<%= link_to 'here' => '/perldoc' %>.
@@ layouts/default.html.ep
<!DOCTYPE html>
<html>
<head><title><%= title %></title></head>
<body><%= content %></body>
</html>
@@ reverse.html.ep
% layout 'default';
% title 'reverse';
<%= content %>
Zum testen aufgerufen:
T:\>perl myapp.pl get -M PUT -c '{"test":1234567}' /reverse
[Sat Jan 21 09:52:09 2017] [debug] PUT "/reverse"
[Sat Jan 21 09:52:09 2017] [debug] Routing to a callback
Use of uninitialized value in reverse at myapp.pl line 20.
[Sat Jan 21 09:52:09 2017] [debug] 200 OK (0.013161s, 75.982/s)
{"test":""}
Sieht so aus als würde JSON nicht erkannt!?
wie kann ich das denn anders testen?
Last edited: 2017-01-21 10:06:22 +0100 (CET)