Having route like this in my code:

get '/json_url' => sub {
  my $self = shift;
  my $res = $self->ua->get($api_url => form => \%hash)->res;
  $self->render(json => $res );
};

But when I try to get json via command line and grab it to file I got a 500 
Error:

pavel@pavel-VBox-Lubuntu:~/projects/...$ ./myapp.pl get /json_url
[Thu Feb  4 14:29:15 2016] [debug] GET "/json_url"
[Thu Feb  4 14:29:15 2016] [debug] Routing to a callback
[Thu Feb  4 14:29:15 2016] [error] Mojo::IOLoop already running at /usr/
local/share/perl/5.18.2/Mojo/UserAgent.pm line 60.
[Thu Feb  4 14:29:15 2016] [debug] Template "exception.development.html.ep" 
not found
[Thu Feb  4 14:29:15 2016] [debug] Template "exception.html.ep" not found
[Thu Feb  4 14:29:15 2016] [debug] Rendering template "mojo/debug.html.ep"
[Thu Feb  4 14:29:15 2016] [debug] Rendering template "mojo/menubar.html.ep"
[Thu Feb  4 14:29:15 2016] [debug] Your secret passphrase needs to be 
changed
[Thu Feb  4 14:29:15 2016] [debug] 500 Internal Server Error (0.086742s, 
11.528/s)


Same way with rendering html templates. 

I noticed that problem only happens if I make in a route code request to 
external API via Mojolicious::UserAgent 
<https://metacpan.org/pod/Mojo::UserAgent>. Simple json/html rendering like 
this:

get '/json_test' => sub {
  my $self = shift;
  $self->render(json => "ok");
};

pavel@pavel-VBox-Lubuntu:~/projects/...$ ./myapp.pl get /json_test
[Thu Feb  4 14:41:01 2016] [debug] Reading configuration file 
"/home/pavel/projects/kayako-scoreboard/myapp.conf"
[Thu Feb  4 14:41:01 2016] [debug] GET "/json_test"
[Thu Feb  4 14:41:01 2016] [debug] Routing to a callback
[Thu Feb  4 14:41:01 2016] [debug] 200 OK (0.001050s, 952.381/s)
"ok"

 works fine.

I'm using latest Mojolicious version, 6.43.

Have no idea why described problem happens, please help me. Do I need to 
format routes to non-blocking if I need to use them via command line?

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to