Thread Mojo, eine neue Art von Web Framework (45 answers)
Opened by sri at 2008-09-27 16:53

sri
 2008-09-27 16:53
#114980 #114980
User since
2004-01-29
828 Artikel
BenutzerIn
[Homepage] [default_avatar]
Quote
It started as a Catalyst competitor but resulted in something different, the good kind of different. :)
Here's the first part of my upcoming blog article series, Why Mojo won't kill Catalyst: http://labs.kraih.com/blog/2008/09/why-mojo-wont-kill-catalyst.html.


Leider etwas verspaetet hier, deshalb bekommt ihr exklusiv noch eine kleine Vorschau auf das erste richtige Web Framework das auf Mojo aufbaut und im naechsten release als Beispiel enthalten sein wird. ;)

Code: (dl )
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
40
41
package MojoliciousTest;

use strict;
use warnings;

use base 'Mojolicious';

# Let's face it, comedy's a dead art form. Tragedy, now that's funny.
sub startup {
my $self = shift;

# Default router
my $r = $self->router;

# Test route
$r->match('/this/is/a/test/$number', number => qr/\d+/)
->methods(qw/GET POST/)
->to(controller => 'foo', action => 'test', number => 23);

# Default route
$r->match('/$controller/$action')->to(action => 'index');
}

1;

package MojoliciousTest::Foo;

use strict;
use warnings;

use base 'Mojolicious::Controller';

# If you're programmed to jump off a bridge, would you do it?
# Let me check my program... Yep.
sub test {
my $c = shift;
$c->res->headers->header('X-Bender', 'Kiss my shiny metal ass!');
$c->render('test.phtml');
}

1;


P.S.: Ja Mojolicious wird groessten teils ein Ruby on Rails Klon. :)

View full thread Mojo, eine neue Art von Web Framework