Intro to API Development with Mojolicous Matt Monsen.
-
Upload
madlyn-leonard -
Category
Documents
-
view
217 -
download
0
Transcript of Intro to API Development with Mojolicous Matt Monsen.
![Page 1: Intro to API Development with Mojolicous Matt Monsen.](https://reader031.fdocuments.us/reader031/viewer/2022032702/56649ccf5503460f9499a996/html5/thumbnails/1.jpg)
Intro to API Development with MojolicousMatt Monsen
![Page 2: Intro to API Development with Mojolicous Matt Monsen.](https://reader031.fdocuments.us/reader031/viewer/2022032702/56649ccf5503460f9499a996/html5/thumbnails/2.jpg)
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 Matt Monsen.](https://reader031.fdocuments.us/reader031/viewer/2022032702/56649ccf5503460f9499a996/html5/thumbnails/3.jpg)
Installation
$ curl get.mojolicio.us | sh
![Page 4: Intro to API Development with Mojolicous Matt Monsen.](https://reader031.fdocuments.us/reader031/viewer/2022032702/56649ccf5503460f9499a996/html5/thumbnails/4.jpg)
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 Matt Monsen.](https://reader031.fdocuments.us/reader031/viewer/2022032702/56649ccf5503460f9499a996/html5/thumbnails/5.jpg)
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 Matt Monsen.](https://reader031.fdocuments.us/reader031/viewer/2022032702/56649ccf5503460f9499a996/html5/thumbnails/6.jpg)
Getting Started
To run this example with the built-in development web server
![Page 7: Intro to API Development with Mojolicous Matt Monsen.](https://reader031.fdocuments.us/reader031/viewer/2022032702/56649ccf5503460f9499a996/html5/thumbnails/7.jpg)
![Page 8: Intro to API Development with Mojolicous Matt Monsen.](https://reader031.fdocuments.us/reader031/viewer/2022032702/56649ccf5503460f9499a996/html5/thumbnails/8.jpg)
![Page 9: Intro to API Development with Mojolicous Matt Monsen.](https://reader031.fdocuments.us/reader031/viewer/2022032702/56649ccf5503460f9499a996/html5/thumbnails/9.jpg)
$ 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 Matt Monsen.](https://reader031.fdocuments.us/reader031/viewer/2022032702/56649ccf5503460f9499a996/html5/thumbnails/10.jpg)
$ 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 Matt Monsen.](https://reader031.fdocuments.us/reader031/viewer/2022032702/56649ccf5503460f9499a996/html5/thumbnails/11.jpg)
Routing – Controller – Action
![Page 12: Intro to API Development with Mojolicous Matt Monsen.](https://reader031.fdocuments.us/reader031/viewer/2022032702/56649ccf5503460f9499a996/html5/thumbnails/12.jpg)
Rendering
![Page 13: Intro to API Development with Mojolicous Matt Monsen.](https://reader031.fdocuments.us/reader031/viewer/2022032702/56649ccf5503460f9499a996/html5/thumbnails/13.jpg)
Rendering
![Page 14: Intro to API Development with Mojolicous Matt Monsen.](https://reader031.fdocuments.us/reader031/viewer/2022032702/56649ccf5503460f9499a996/html5/thumbnails/14.jpg)
Deployment
CGIPSGI
Daemon
![Page 15: Intro to API Development with Mojolicous Matt Monsen.](https://reader031.fdocuments.us/reader031/viewer/2022032702/56649ccf5503460f9499a996/html5/thumbnails/15.jpg)
Deployment
Daemon
MorboDevelopment Server
HypnotoadHot-code reloading production server
![Page 16: Intro to API Development with Mojolicous Matt Monsen.](https://reader031.fdocuments.us/reader031/viewer/2022032702/56649ccf5503460f9499a996/html5/thumbnails/16.jpg)
Deployment
Run Development Mode$ morbo script/helloServer available at http://127.0.0.1:3000
Morbo
![Page 17: Intro to API Development with Mojolicous Matt Monsen.](https://reader031.fdocuments.us/reader031/viewer/2022032702/56649ccf5503460f9499a996/html5/thumbnails/17.jpg)
Deployment
Run & Reload$ hypnotoad script/hello
Stop$ hypnotoad –s script/hello
Hypnotoad
![Page 18: Intro to API Development with Mojolicous Matt Monsen.](https://reader031.fdocuments.us/reader031/viewer/2022032702/56649ccf5503460f9499a996/html5/thumbnails/18.jpg)
Testing
![Page 19: Intro to API Development with Mojolicous Matt Monsen.](https://reader031.fdocuments.us/reader031/viewer/2022032702/56649ccf5503460f9499a996/html5/thumbnails/19.jpg)
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 Matt Monsen.](https://reader031.fdocuments.us/reader031/viewer/2022032702/56649ccf5503460f9499a996/html5/thumbnails/20.jpg)
![Page 21: Intro to API Development with Mojolicous Matt Monsen.](https://reader031.fdocuments.us/reader031/viewer/2022032702/56649ccf5503460f9499a996/html5/thumbnails/21.jpg)
![Page 22: Intro to API Development with Mojolicous Matt Monsen.](https://reader031.fdocuments.us/reader031/viewer/2022032702/56649ccf5503460f9499a996/html5/thumbnails/22.jpg)
Mojocasts.com