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
import mojo from '@mojojs/core'; | |
const app = mojo(); | |
// TO MAKE THE MAP APPEAR YOU MUST | |
// ADD YOUR ACCESS TOKEN FROM | |
// https://account.mapbox.com | |
const apiKey = 'your token here'; | |
app.any('/', async ctx => { | |
ctx.stash.proxyUrl = ctx.urlFor('proxy-route', {absolute: true}).replace(/\/$/, ''); | |
await ctx.render({inline: indexTemplate}); |
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 Mojo::Base -strict; | |
use Test::Mojo; | |
use Test::More; | |
use Mojolicious::Lite; | |
get '/' => sub {shift->render(text => 'Hello!')}; | |
del '/droute' => sub {shift->redirect_to('/')}; | |
my $t = Test::Mojo->new; | |
$t->ua->max_redirects(1); |
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 Mojo::Base -strict; | |
use Test::More tests => 1; | |
use Mojo::Base -async_await; | |
async sub hello_p { | |
return 'Hello Mojo!'; | |
} | |
hello_p()->then(sub {ok 1})->wait; |
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
# | |
# when you run this code, you don't get a line with "DESTROY called for two" | |
# as I guess it should be the case | |
# | |
# Is this behavior right? How can I force the DESTROY method to be called | |
# on a "started" object? | |
{ | |
package MyServer; | |
use Mojo::Base 'Mojo::EventEmitter'; |
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 strict; | |
use warnings; | |
use v5.10; | |
# this script should never give you the "Error (undef)" line. | |
# however, and depending on where you run it, you will get it time to time. | |
# For instance, running this on my macbook (perl 5.28.1, Mojolicious 8.14): | |
# | |
# $> for i in {1..20};do perl ldtest.pl;done | |
# # 3: Error (undef) |