Mojolicious
Upcoming SlideShare
Loading in...5
×
 

Mojolicious

on

  • 3,532 views

 

Statistics

Views

Total Views
3,532
Views on SlideShare
3,382
Embed Views
150

Actions

Likes
1
Downloads
29
Comments
0

5 Embeds 150

http://norbu09.org 140
http://www.slideshare.net 7
http://localhost:4000 1
http://www.lmodules.com 1
http://flavors.me 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Mojolicious Mojolicious Presentation Transcript

  • Mojolicious
  • Catalyst welcome to dependency hell
  • vs
  • cpan Mojo only core dependencies
  • catalyst.pl new_project created "new_project" created "new_project/script" created "new_project/lib" [ snip ] created "new_project/script/new_project_server.pl" created "new_project/script/new_project_test.pl" created "new_project/script/new_project_create.pl"
  • mojolicious generate lite_app new_project [exist] /private/tmp [write] /private/tmp/new_project [chmod] new_project 744
  • ./new_project daemon
  • Yea baby!
  • where does it come from
  • #!/usr/bin/env perl use Mojolicious::Lite; get '/' => 'index'; get '/:groovy' => sub { my $self = shift; $self->render_text($self->param('groovy'), layout => 'funky'); }; app->start; __DATA__ @@ index.html.ep % layout 'funky'; Yea baby! @@ layouts/funky.html.ep <!doctype html><html> <head><title>Funky!</title></head> <body><%== content %></body> </html>
  • what is it good for why bother - why another framework
  • extremely quick and dirty ideal for prototyping
  • @@ index.html.ep <!doctype html><html> <head><title>EPP test client</title></head> <body> % if ($result) { <h2>EPP greeting</h2> <pre> <%= $greet %> </pre> <h2>EPP command results</h2> % foreach my $res (@{$result->{results}}) { <pre> <%= $res %> </pre> % } % } <form method="post"> <textarea rows="20" cols="40" name="command"> <%= $command %> </textarea> <br /> <input type="submit" name="submit" value="send command" /> </form> </body> </html>
  • can scale out and become nice and clean
  • some nice features
  • query CouchDB my $client = Mojo::Client->new; my $url = $couch_user_url. "?key="'.$self->session->{'name'}.'"'; my $view = $client->get($url)->success->json->{rows}->[0]-> {doc};
  • routing • get ‘/foo’ => (agent qr/iPhone/) => sub { • post ‘/foo’ => sub { #all treated the same } • any => sub { #catch all } • ladder sub { return 1;} #authentication
  • output format • $self->render_json($data) • $self->render_text(“Hi there!”) • $self->render(handler => [your handler])
  • and once you grow out of the lite_app
  • mojolicious inflate new_project
  • have fun prototyping
  • Lenz Gschwendtner @norbu09