intro to api development with mojolicous

22
Intro to API Development with Mojolicous Matt Monsen

Upload: leia

Post on 24-Feb-2016

23 views

Category:

Documents


0 download

DESCRIPTION

Intro to API Development with Mojolicous. Matt Monsen. Features. An amazing real-time web framework. Very clean, portable and Object Oriented pure-Perl API. Full stack HTTP and WebSocket client/server implementation. Built-in non-blocking I/O web server. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Intro to API Development with  Mojolicous

Intro to API Development with MojolicousMatt Monsen

Page 2: Intro to API Development with  Mojolicous

Features An amazing real-time web framework.

Very clean, portable and Object Oriented pure-Perl API.

Full stack HTTP and WebSocket client/server implementation.

Built-in non-blocking I/O web server.

Automatic CGI and PSGI detection.

JSON and HTML/XML parser with CSS selector support.

Page 3: Intro to API Development with  Mojolicous

Installation

$ curl get.mojolicio.us | sh

Page 4: Intro to API Development with  Mojolicous

Getting Started

use Mojolicious::Lite;

get '/' => { text => ’I <3 Perl!’ };

app->start;

These three lines are a whole web application

Page 5: Intro to API Development with  Mojolicous

Getting Started

$ morbo perl.pl Server available at http://127.0.0.1:3000.

$ curl http://127.0.0.1:3000/ I <3 Perl!

To run this example with the built-in development web server

Page 6: Intro to API Development with  Mojolicous

Getting Started

To run this example with the built-in development web server

Page 7: Intro to API Development with  Mojolicous
Page 8: Intro to API Development with  Mojolicous
Page 9: Intro to API Development with  Mojolicous

$ mojo generate app Hello [mkdir] /home/matt/hello/script [write] /home/matt/hello/script/hello [chmod] hello/script/hello 744 [mkdir] /home/matt/hello/lib [write] /home/matt/hello/lib/Hello.pm [mkdir] /home/matt/hello/lib/Hello [write] /home/matt/hello/lib/Hello/Example.pm [mkdir] /home/matt/hello/t [write] /home/matt/hello/t/basic.t [mkdir] /home/matt/hello/log [mkdir] /home/matt/hello/public [write] /home/matt/hello/public/index.html [mkdir] /home/matt/hello/templates/layouts [write] /home/matt/hello/templates/layouts/default.html.ep [mkdir] /home/matt/hello/templates/example [write] /home/matt/hello/templates/example/welcome.html.ep

Page 10: Intro to API Development with  Mojolicous

$ mojo generate app Hello [mkdir] /home/matt/hello/script [write] /home/matt/hello/script/hello [chmod] hello/script/hello 744 [mkdir] /home/matt/hello/lib [write] /home/matt/hello/lib/Hello.pm [mkdir] /home/matt/hello/lib/Hello [write] /home/matt/hello/lib/Hello/Example.pm [mkdir] /home/matt/hello/t [write] /home/matt/hello/t/basic.t [mkdir] /home/matt/hello/log [mkdir] /home/matt/hello/public [write] /home/matt/hello/public/index.html [mkdir] /home/matt/hello/templates/layouts [write] /home/matt/hello/templates/layouts/default.html.ep [mkdir] /home/matt/hello/templates/example [write] /home/matt/hello/templates/example/welcome.html.ep

Page 11: Intro to API Development with  Mojolicous

Routing – Controller – Action

Page 12: Intro to API Development with  Mojolicous

Rendering

Page 13: Intro to API Development with  Mojolicous

Rendering

Page 14: Intro to API Development with  Mojolicous

Deployment

CGIPSGI

Daemon

Page 15: Intro to API Development with  Mojolicous

DeploymentDaemon

MorboDevelopment Server

HypnotoadHot-code reloading production server

Page 16: Intro to API Development with  Mojolicous

Deployment

Run Development Mode$ morbo script/helloServer available at http://127.0.0.1:3000

Morbo

Page 17: Intro to API Development with  Mojolicous

Deployment

Run & Reload$ hypnotoad script/hello

Stop$ hypnotoad –s script/hello

Hypnotoad

Page 18: Intro to API Development with  Mojolicous

Testing

Page 19: Intro to API Development with  Mojolicous

Testing

$ perl script/hello testRunning tests from '/home/matt/hello/t’.script/../t/basic.t .. okAll tests successful.Files=1, Tests=3, 1 wallclock secs ( 0.03 usr 0.01 sys + 0.32 cusr 0.04 csys = 0.40 CPU)Result: PASS

Page 20: Intro to API Development with  Mojolicous
Page 21: Intro to API Development with  Mojolicous
Page 22: Intro to API Development with  Mojolicous

Mojocasts.com