[Mojolicious] Re: mojolicious template if statement

2018-03-06 Thread Andrew Morgan
Argh..lol, thank you very much..rookie mistake.

Thank you 

On Monday, 5 March 2018 22:51:23 UTC-5, Andrew Morgan wrote:
>
> Hello All,
>
> I have the below code, but the if statement is not functioning.No matter 
> what my selection is in the browser it returns "you entered correct car 
> "
>
> Please assist.Thank you 
>
>
> use Mojolicious::Lite;
>
>
> get '/' => sub {
>
>
> my $self = shift;
> $self->render('index');
> };
>
>
> post '/action' => sub{
> my $c = shift;
> $c->render('response', msg => $c->param('cars'));
> };
>
>
> app->start;
>
>
> __DATA__
>
>
> @@ index.html.ep
>
>
> 
> 
> 
>
>
> 
>   
> Volvo
> Saab
> Fiat
> Audi
>   
>   
>   
> 
>
>
> 
> 
>
>
> @@ response.html.ep
>
>
> %if($msg == "fiat"){
> You entered the correct car <%= $msg %>
> %}else{
> You did rubbish!! <%= $msg %>
> %}
>
>

-- 
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 mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Why it works with blocking code?

2018-03-06 Thread Michael Fung
Hi,

I need to use MongoDB(I know it is not recommended here). I used the 
official MongoDB driver like this:

startup {
  ...
  $app->helper( 'sem' => sub { state $sem = Coro::Semaphore->new(5); });  


   my @mongo_clients = ();
$app->defaults({ mongo_clients => \@mongo_clients });
for ( 1 .. 5 ) {
push @mongo_clients, MongoDB->connect(
'mongodb://webapi:test1234@localhost:27017/wfh');
}


controller_action {
   ...
my $guard = $c->sem->guard;
my $mongo = $c->stash('mongo_clients')->[($c->sem->count -1)];
my $users_coll = $mongo->ns('wfh.users');
my $q = {user_id => 181001};
my $doc = $users_coll->find_one( $q );


I tried some basic load testing with apache's "ab". It works. But why? 
Isn't Mojo supposed to fail with blocking code?


-- 
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 mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.