SlideShare a Scribd company logo
1 of 29
Download to read offline
Angelos github.com/dann dann
How to develop
Modern WAF
dann
techmemo@gmail.com
YAPC::Asia 2009 2009/09/10
Angelos github.com/dann dann
About Me
•Dann
•Creator of Angelos
•Yet Another WAF
•http://github.com/dann/
Angelos github.com/dann dann
Presentation Overview
•What is modern web application
framework?
•How to develop the minimal
elements of modern WAF
•How to develop the plugin
architecture of WAF
Angelos github.com/dann dann
What is modern WAF?
•Fullstack like Rails
•Pluggable like Plagger
•Server Abstraction like WSGI
•Separete WAF and App
Usability
Extendability
Testability
Angelos github.com/dann dann
How to develop
the basic elements
of WAF
Angelos github.com/dann dann
The basic elements
Component
ManagerDispatcher
Engine
recieve a request and return a
response
(Server Abstraction)
URL to Controller
resolver Load and search component
Angelos github.com/dann dann
Basic Sequence of WAF
②
①
③
④
⑤
⑥
Angelos github.com/dann dann
Engine - Angelos::Engine
sub build_engine {
my $self = shift;
my $request_handler = $self->request_handler;
$request_handler ||= $self->build_request_handler;
return Angelos::PSGI::Engine->new(
interface => {
module => $self->server,
....
},
psgi_handler => $request_handler,
);
} psgi handler which is passed to
the server gateay
the type of server
gateway
Angelos github.com/dann dann
Engine - Angelos::PSGI::Engine
use Mouse;
use Angelos::Types qw( ServerGateway );
 
has 'interface' => (
    is => 'ro',
    isa => ServerGateway,
    coerce => 1,
);
 
has 'psgi_handler' => ( is => 'rw', );
 
sub run {
    my $self = shift;
    $self->interface->run( $self->psgi_handler );
}
pass psgi handler to server
gateway
Create Server Gateway
Angelos github.com/dann dann
Create Server Gateway
package Angelos::PSGI::ServerGatewayBuilder;
use strict;
use warnings;
use Plack::Loader;
sub build {
my ( $class, $module, $args ) = @_;
my $server_gateway = Plack::Loader->load( $module,
%{$args} );
$server_gateway;
}
Create server gateway with
Plack::Loader
Angelos github.com/dann dann
psgi handler s code
...
sub {
my $env = shift;
my $req = Angelos::Request->new($env);
my $res = $self->handle_request($req);
my $psgi_res = $self->finalize_response($res);
return $psgi_res;
}
... return PSGI response
recieve PSGI env
and convert it to WAF Request
Angelos github.com/dann dann
Request Handler - Angelos::Engine::Base
sub handle_request {
my ( $self, $req ) = @_;
eval { $self->DISPATCH($req); };
if ( my $e = Exception::Class->caught() ) {
$self->HANDLE_EXCEPTION($e);
}
# return response
return $self->context->res;
}
②dispatch request to
Dispatcher
①recive a request
Angelos github.com/dann dann
Dispatching
sub DISPATCH {
my ( $self, $req ) = @_;
my $dispatch = $self->dispatcher->dispatch($req);
...
$dispatch->run;
# return response
$c->res;
}
② Dispatch a request do
dispatcher
Angelos github.com/dann dann
Angelos::Dispatcher
sub dispatch {
my ( $self, $request ) = @_;
my $match = $self->router->match($request);
my $dispatch = $self->dispatch_class->new( match =>
$match );
return $dispatch;
}
③ <URL to Controller>
search controller name
based on the request path
with HTTP::Router
④ Create dispatch
instance
Angelos github.com/dann dann
Angelos::Dispatcher::Dispatch
my $controller = $match->params->{controller};
my $controller_instance = $self-
>find_controller_instance(
{ context => $c,
controller => $controller,
}
);
...
$controller_instance->_dispatch_action( $action,
$params );
⑤ search a controller
instance from Component
Manager
⑥ execute Controller’s
action and return response.
Angelos github.com/dann dann
Routing
HTTP::Router->define(
sub {
$_->match('/')->to( { controller => 'Root', action
=> 'index' } );
$_->resources('Book');
}
);
conf/routes.pl- define routing information
Angelos github.com/dann dann
Routing Table
.----------------------------------------------+------------+------------+--------------.
| path | method | controller | action |
+---------------------------------------------+------------+------------+------------+
| / | | Root | index |
| /book.{format} | POST | Books | create |
| /book | POST | Books | create |
| /book.{format} | GET | Books | index |
| /book | GET | Books | index |
| /book/new.{format} | GET | Books | post |
| /book/new | GET | Books | post |
| /book/{book_id}.{format} | GET | Books | show |
| /book.{format} | POST | Books | create |
| /book | POST | Books | create |
| /book.{format} | GET | Books | index |
| /book.{bookk_id}.{format} | DELETE | Books | destroy |
| /book/{book_id} | DELETE | Books | destroy |
| /book/{book_id}.{format} | PUT | Books | update |
| /book/{book_id} | PUT | Books | update |
'-----------------------------------------------+------------+------------+-------------
Angelos github.com/dann dann
Finished developing basic
elements of WAF
•It’s really easy to develop basic
elements of WAF
•You can develop simple WAF
like Sinatra in 4 or 5 hours
Angelos github.com/dann dann
How to develop the plugin
architecture of WAF
Angelos github.com/dann dann
How to development the plugin
architecture of WAF
• What the plugin architecture of WAF
SHOULD be
• The type of Plugins
• How to develop plugin architecture of
WAF
• Example: the plugin of Angelos
Angelos github.com/dann dann
What the plugin architecture of WAF SHOULD
• the core elements of WAF should be as
small as possible and the all parts of WAF
should be extendable and pluggable
• The scope of plugin should be limeted
• Controller,View, Middleware, Request,
Response
• Extension point must be declaretive
Angelos github.com/dann dann
The types of Plugins
•Hook WAF’s Lifecycle
•Add methods to WAF’s class
Angelos github.com/dann dann
Plugin Implementation
• Hook WAF’s lifecycle
• Mouse’s Role + method modifier
• Class::Trigger
• MouseX::Object::Pluggable
• Add methods to WAF’s classes
• Mouse’s Role
• Exporter
• Multiple inheritance
Angelos github.com/dann dann
How to develop plugin in Angelos
• Make Plugin as Role
• User consume plugins in the WAF Component
• Hook WAF’s lifecycle with method modifier
• hook Component’s hook point
• Declare hook point method with CAPITAL
character
Angelos github.com/dann dann
Hook point example
sub _dispatch_action {
my ( $self, $action, $params ) = @_;
...
eval { $self->ACTION( $self->context, $action, $params ); };
...
}
Declare hook point with
Capital character
Angelos github.com/dann dann
the code of Plugin
before 'ACTION' => sub {
my ( $self, $c, $action, $params ) = @_;
$self->__action_start_time( time() );
};
after 'ACTION' => sub {
my ( $self, $c, $action, $params ) = @_;
$self->__action_end_time( time() );
my $elapsed = $self->__action_end_time - $self-
>__action_start_time;
my $message
= "action processing time:naction: $action ntime : $elapsed
secsn";
$self->log->info($message);
};
Angelos github.com/dann dann
What The WAF developer should do
• WAF developer should make default plugin sets
which user should use
• if there aren’t default plugins sets...
• How can I use Unicode in WAF?
• ... UseXXX,YYY...
• How can I inflate datetime? ...
Angelos github.com/dann dann
Conclusion
• The basic elements of WAF
• Engine, Dispatcher, Component Loader
• WAF’s plugin
• Hook WAF Lifecycle or add a Method to the
Component of WAF
• Plugin Scope must be limited
• the plugin and plugins default sets should be
provided by WAF developer
Angelos github.com/dann dann
Fin.
• It’s really easy to implement WAF now
• Let’s develop modern WAF with us ;)
• Repository
• http://github.com/dann/angelos/tree/master

More Related Content

What's hot

Perl web frameworks
Perl web frameworksPerl web frameworks
Perl web frameworksdiego_k
 
Silex: From nothing to an API
Silex: From nothing to an APISilex: From nothing to an API
Silex: From nothing to an APIchrisdkemper
 
Webrtc mojo
Webrtc mojoWebrtc mojo
Webrtc mojobpmedley
 
Keeping it Small: Getting to know the Slim Micro Framework
Keeping it Small: Getting to know the Slim Micro FrameworkKeeping it Small: Getting to know the Slim Micro Framework
Keeping it Small: Getting to know the Slim Micro FrameworkJeremy Kendall
 
Keeping it small - Getting to know the Slim PHP micro framework
Keeping it small - Getting to know the Slim PHP micro frameworkKeeping it small - Getting to know the Slim PHP micro framework
Keeping it small - Getting to know the Slim PHP micro frameworkJeremy Kendall
 
Introducing Assetic (NYPHP)
Introducing Assetic (NYPHP)Introducing Assetic (NYPHP)
Introducing Assetic (NYPHP)Kris Wallsmith
 
Inside Bokete: Web Application with Mojolicious and others
Inside Bokete:  Web Application with Mojolicious and othersInside Bokete:  Web Application with Mojolicious and others
Inside Bokete: Web Application with Mojolicious and othersYusuke Wada
 
10 tips for making Bash a sane programming language
10 tips for making Bash a sane programming language10 tips for making Bash a sane programming language
10 tips for making Bash a sane programming languageYaroslav Tkachenko
 
Building Modern and Secure PHP Applications – Codementor Office Hours with Be...
Building Modern and Secure PHP Applications – Codementor Office Hours with Be...Building Modern and Secure PHP Applications – Codementor Office Hours with Be...
Building Modern and Secure PHP Applications – Codementor Office Hours with Be...Arc & Codementor
 
And the Greatest of These Is ... Rack Support
And the Greatest of These Is ... Rack SupportAnd the Greatest of These Is ... Rack Support
And the Greatest of These Is ... Rack SupportBen Scofield
 
ISUCONアプリを Pythonで書いてみた
ISUCONアプリを Pythonで書いてみたISUCONアプリを Pythonで書いてみた
ISUCONアプリを Pythonで書いてみたmemememomo
 
Asynchronous programming patterns in Perl
Asynchronous programming patterns in PerlAsynchronous programming patterns in Perl
Asynchronous programming patterns in Perldeepfountainconsulting
 
Slim RedBeanPHP and Knockout
Slim RedBeanPHP and KnockoutSlim RedBeanPHP and Knockout
Slim RedBeanPHP and KnockoutVic Metcalfe
 
Putting the Cat in the Catalogue: A Feline-Inspired OPAC Theme For Koha
Putting the Cat in the Catalogue: A Feline-Inspired OPAC Theme For KohaPutting the Cat in the Catalogue: A Feline-Inspired OPAC Theme For Koha
Putting the Cat in the Catalogue: A Feline-Inspired OPAC Theme For KohaGalen Charlton
 

What's hot (20)

Developing apps using Perl
Developing apps using PerlDeveloping apps using Perl
Developing apps using Perl
 
Perl web frameworks
Perl web frameworksPerl web frameworks
Perl web frameworks
 
Silex: From nothing to an API
Silex: From nothing to an APISilex: From nothing to an API
Silex: From nothing to an API
 
Webrtc mojo
Webrtc mojoWebrtc mojo
Webrtc mojo
 
Keeping it Small: Getting to know the Slim Micro Framework
Keeping it Small: Getting to know the Slim Micro FrameworkKeeping it Small: Getting to know the Slim Micro Framework
Keeping it Small: Getting to know the Slim Micro Framework
 
Keeping it small - Getting to know the Slim PHP micro framework
Keeping it small - Getting to know the Slim PHP micro frameworkKeeping it small - Getting to know the Slim PHP micro framework
Keeping it small - Getting to know the Slim PHP micro framework
 
Complex Sites with Silex
Complex Sites with SilexComplex Sites with Silex
Complex Sites with Silex
 
Introducing Assetic (NYPHP)
Introducing Assetic (NYPHP)Introducing Assetic (NYPHP)
Introducing Assetic (NYPHP)
 
Mojolicious
MojoliciousMojolicious
Mojolicious
 
Inside Bokete: Web Application with Mojolicious and others
Inside Bokete:  Web Application with Mojolicious and othersInside Bokete:  Web Application with Mojolicious and others
Inside Bokete: Web Application with Mojolicious and others
 
10 tips for making Bash a sane programming language
10 tips for making Bash a sane programming language10 tips for making Bash a sane programming language
10 tips for making Bash a sane programming language
 
Building Modern and Secure PHP Applications – Codementor Office Hours with Be...
Building Modern and Secure PHP Applications – Codementor Office Hours with Be...Building Modern and Secure PHP Applications – Codementor Office Hours with Be...
Building Modern and Secure PHP Applications – Codementor Office Hours with Be...
 
And the Greatest of These Is ... Rack Support
And the Greatest of These Is ... Rack SupportAnd the Greatest of These Is ... Rack Support
And the Greatest of These Is ... Rack Support
 
dotCloud and go
dotCloud and godotCloud and go
dotCloud and go
 
ISUCONアプリを Pythonで書いてみた
ISUCONアプリを Pythonで書いてみたISUCONアプリを Pythonで書いてみた
ISUCONアプリを Pythonで書いてみた
 
Asynchronous programming patterns in Perl
Asynchronous programming patterns in PerlAsynchronous programming patterns in Perl
Asynchronous programming patterns in Perl
 
Slim RedBeanPHP and Knockout
Slim RedBeanPHP and KnockoutSlim RedBeanPHP and Knockout
Slim RedBeanPHP and Knockout
 
RESTful web services
RESTful web servicesRESTful web services
RESTful web services
 
Mojo as a_client
Mojo as a_clientMojo as a_client
Mojo as a_client
 
Putting the Cat in the Catalogue: A Feline-Inspired OPAC Theme For Koha
Putting the Cat in the Catalogue: A Feline-Inspired OPAC Theme For KohaPutting the Cat in the Catalogue: A Feline-Inspired OPAC Theme For Koha
Putting the Cat in the Catalogue: A Feline-Inspired OPAC Theme For Koha
 

Viewers also liked

I know how to search the internet,
I know how to search the internet,I know how to search the internet,
I know how to search the internet,Hindie Dershowitz
 
Calculate your Water Footprint at H2O Conserve
Calculate your Water Footprint at H2O ConserveCalculate your Water Footprint at H2O Conserve
Calculate your Water Footprint at H2O Conserveguest5961519
 
The Modern Web, Part 1: Mobility
The Modern Web, Part 1: MobilityThe Modern Web, Part 1: Mobility
The Modern Web, Part 1: MobilityDavid Pallmann
 
How to search the Internet, a guide to save time and effort
How to search the Internet, a guide to save time and effortHow to search the Internet, a guide to save time and effort
How to search the Internet, a guide to save time and effortPete S
 
Google webmaster guide for starters
Google webmaster guide for startersGoogle webmaster guide for starters
Google webmaster guide for startersjatindsim
 
Windows 8 and the Cloud
Windows 8 and the CloudWindows 8 and the Cloud
Windows 8 and the CloudDavid Pallmann
 
Web of knowledge advanced features
Web of knowledge advanced featuresWeb of knowledge advanced features
Web of knowledge advanced featuresLisa Hartman
 
WATER FOOTPRINT ACCOUNTING FOR CATCHMENTS AND RIVER BASINS
WATER FOOTPRINT ACCOUNTING FOR CATCHMENTS AND RIVER BASINSWATER FOOTPRINT ACCOUNTING FOR CATCHMENTS AND RIVER BASINS
WATER FOOTPRINT ACCOUNTING FOR CATCHMENTS AND RIVER BASINSGlorynel Ojeda-Matos
 
Internet Search Tips featuring Google
Internet Search Tips featuring GoogleInternet Search Tips featuring Google
Internet Search Tips featuring GoogleLisa Hartman
 
Internet Search
Internet SearchInternet Search
Internet SearchD Houseman
 
The Modern Web Part 3: Social Networking
The Modern Web Part 3: Social NetworkingThe Modern Web Part 3: Social Networking
The Modern Web Part 3: Social NetworkingDavid Pallmann
 
Internet Search Tips (Google)
Internet Search Tips (Google)Internet Search Tips (Google)
Internet Search Tips (Google)Lisa Hartman
 
Debugging and Tuning Mobile Web Sites with Modern Web Browsers
Debugging and Tuning Mobile Web Sites with Modern Web BrowsersDebugging and Tuning Mobile Web Sites with Modern Web Browsers
Debugging and Tuning Mobile Web Sites with Modern Web BrowsersTroy Miles
 
Manuele Margni, CIRAIG - Behind the Water Footprint Stream: Metrics and Initi...
Manuele Margni, CIRAIG - Behind the Water Footprint Stream: Metrics and Initi...Manuele Margni, CIRAIG - Behind the Water Footprint Stream: Metrics and Initi...
Manuele Margni, CIRAIG - Behind the Water Footprint Stream: Metrics and Initi...CWS_2010
 
The Modern Web, Part 2: HTML5
The Modern Web, Part 2: HTML5The Modern Web, Part 2: HTML5
The Modern Web, Part 2: HTML5David Pallmann
 
Using the internet for search
Using the internet for searchUsing the internet for search
Using the internet for searchDr-Heba Mustafa
 
When worlds Collide: HTML5 Meets the Cloud
When worlds Collide: HTML5 Meets the CloudWhen worlds Collide: HTML5 Meets the Cloud
When worlds Collide: HTML5 Meets the CloudDavid Pallmann
 
The water footprint of humanity – the global dimension of water management
The water footprint of humanity – the global dimension of water managementThe water footprint of humanity – the global dimension of water management
The water footprint of humanity – the global dimension of water managementWorld Agroforestry (ICRAF)
 

Viewers also liked (20)

I know how to search the internet,
I know how to search the internet,I know how to search the internet,
I know how to search the internet,
 
Calculate your Water Footprint at H2O Conserve
Calculate your Water Footprint at H2O ConserveCalculate your Water Footprint at H2O Conserve
Calculate your Water Footprint at H2O Conserve
 
The Modern Web, Part 1: Mobility
The Modern Web, Part 1: MobilityThe Modern Web, Part 1: Mobility
The Modern Web, Part 1: Mobility
 
How to search the Internet, a guide to save time and effort
How to search the Internet, a guide to save time and effortHow to search the Internet, a guide to save time and effort
How to search the Internet, a guide to save time and effort
 
Google webmaster guide for starters
Google webmaster guide for startersGoogle webmaster guide for starters
Google webmaster guide for starters
 
Windows 8 and the Cloud
Windows 8 and the CloudWindows 8 and the Cloud
Windows 8 and the Cloud
 
Web of knowledge advanced features
Web of knowledge advanced featuresWeb of knowledge advanced features
Web of knowledge advanced features
 
WATER FOOTPRINT ACCOUNTING FOR CATCHMENTS AND RIVER BASINS
WATER FOOTPRINT ACCOUNTING FOR CATCHMENTS AND RIVER BASINSWATER FOOTPRINT ACCOUNTING FOR CATCHMENTS AND RIVER BASINS
WATER FOOTPRINT ACCOUNTING FOR CATCHMENTS AND RIVER BASINS
 
Internet Search Tips featuring Google
Internet Search Tips featuring GoogleInternet Search Tips featuring Google
Internet Search Tips featuring Google
 
Internet Search
Internet SearchInternet Search
Internet Search
 
The Modern Web Part 3: Social Networking
The Modern Web Part 3: Social NetworkingThe Modern Web Part 3: Social Networking
The Modern Web Part 3: Social Networking
 
Internet Search Tips (Google)
Internet Search Tips (Google)Internet Search Tips (Google)
Internet Search Tips (Google)
 
Debugging and Tuning Mobile Web Sites with Modern Web Browsers
Debugging and Tuning Mobile Web Sites with Modern Web BrowsersDebugging and Tuning Mobile Web Sites with Modern Web Browsers
Debugging and Tuning Mobile Web Sites with Modern Web Browsers
 
Bad websites
Bad websitesBad websites
Bad websites
 
Manuele Margni, CIRAIG - Behind the Water Footprint Stream: Metrics and Initi...
Manuele Margni, CIRAIG - Behind the Water Footprint Stream: Metrics and Initi...Manuele Margni, CIRAIG - Behind the Water Footprint Stream: Metrics and Initi...
Manuele Margni, CIRAIG - Behind the Water Footprint Stream: Metrics and Initi...
 
The Modern Web, Part 2: HTML5
The Modern Web, Part 2: HTML5The Modern Web, Part 2: HTML5
The Modern Web, Part 2: HTML5
 
Using the internet for search
Using the internet for searchUsing the internet for search
Using the internet for search
 
Affordable web design
Affordable web designAffordable web design
Affordable web design
 
When worlds Collide: HTML5 Meets the Cloud
When worlds Collide: HTML5 Meets the CloudWhen worlds Collide: HTML5 Meets the Cloud
When worlds Collide: HTML5 Meets the Cloud
 
The water footprint of humanity – the global dimension of water management
The water footprint of humanity – the global dimension of water managementThe water footprint of humanity – the global dimension of water management
The water footprint of humanity – the global dimension of water management
 

Similar to How to develop modern web application framework

Single Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and JasmineSingle Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and JasminePaulo Ragonha
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the FinishYehuda Katz
 
20130528 solution linux_frousseau_nopain_webdev
20130528 solution linux_frousseau_nopain_webdev20130528 solution linux_frousseau_nopain_webdev
20130528 solution linux_frousseau_nopain_webdevFrank Rousseau
 
Curscatalyst
CurscatalystCurscatalyst
CurscatalystKar Juan
 
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryRemedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryTatsuhiko Miyagawa
 
Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overviewYehuda Katz
 
Using WordPress as your application stack
Using WordPress as your application stackUsing WordPress as your application stack
Using WordPress as your application stackPaul Bearne
 
All I Need to Know I Learned by Writing My Own Web Framework
All I Need to Know I Learned by Writing My Own Web FrameworkAll I Need to Know I Learned by Writing My Own Web Framework
All I Need to Know I Learned by Writing My Own Web FrameworkBen Scofield
 
Quality Use Of Plugin
Quality Use Of PluginQuality Use Of Plugin
Quality Use Of PluginYasuo Harada
 
Summit2011 satellites-robinf-20110605
Summit2011 satellites-robinf-20110605Summit2011 satellites-robinf-20110605
Summit2011 satellites-robinf-20110605Robin Fernandes
 
Satellite Apps around the Cloud: Integrating your infrastructure with JIRA St...
Satellite Apps around the Cloud: Integrating your infrastructure with JIRA St...Satellite Apps around the Cloud: Integrating your infrastructure with JIRA St...
Satellite Apps around the Cloud: Integrating your infrastructure with JIRA St...Atlassian
 
Migrating Legacy Rails Apps to Rails 3
Migrating Legacy Rails Apps to Rails 3Migrating Legacy Rails Apps to Rails 3
Migrating Legacy Rails Apps to Rails 3Clinton Dreisbach
 
The $path to knowledge: What little it take to unit-test Perl.
The $path to knowledge: What little it take to unit-test Perl.The $path to knowledge: What little it take to unit-test Perl.
The $path to knowledge: What little it take to unit-test Perl.Workhorse Computing
 
Optimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
Optimising Your Front End Workflow With Symfony, Twig, Bower and GulpOptimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
Optimising Your Front End Workflow With Symfony, Twig, Bower and GulpMatthew Davis
 
関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐいHisateru Tanaka
 
Railsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshareRailsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slidesharetomcopeland
 
How Bitbucket Pipelines Loads Connect UI Assets Super-fast
How Bitbucket Pipelines Loads Connect UI Assets Super-fastHow Bitbucket Pipelines Loads Connect UI Assets Super-fast
How Bitbucket Pipelines Loads Connect UI Assets Super-fastAtlassian
 

Similar to How to develop modern web application framework (20)

Single Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and JasmineSingle Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
 
Laravel 101
Laravel 101Laravel 101
Laravel 101
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the Finish
 
20130528 solution linux_frousseau_nopain_webdev
20130528 solution linux_frousseau_nopain_webdev20130528 solution linux_frousseau_nopain_webdev
20130528 solution linux_frousseau_nopain_webdev
 
Curscatalyst
CurscatalystCurscatalyst
Curscatalyst
 
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryRemedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
 
Sprockets
SprocketsSprockets
Sprockets
 
Ling framework
Ling frameworkLing framework
Ling framework
 
Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overview
 
Using WordPress as your application stack
Using WordPress as your application stackUsing WordPress as your application stack
Using WordPress as your application stack
 
All I Need to Know I Learned by Writing My Own Web Framework
All I Need to Know I Learned by Writing My Own Web FrameworkAll I Need to Know I Learned by Writing My Own Web Framework
All I Need to Know I Learned by Writing My Own Web Framework
 
Quality Use Of Plugin
Quality Use Of PluginQuality Use Of Plugin
Quality Use Of Plugin
 
Summit2011 satellites-robinf-20110605
Summit2011 satellites-robinf-20110605Summit2011 satellites-robinf-20110605
Summit2011 satellites-robinf-20110605
 
Satellite Apps around the Cloud: Integrating your infrastructure with JIRA St...
Satellite Apps around the Cloud: Integrating your infrastructure with JIRA St...Satellite Apps around the Cloud: Integrating your infrastructure with JIRA St...
Satellite Apps around the Cloud: Integrating your infrastructure with JIRA St...
 
Migrating Legacy Rails Apps to Rails 3
Migrating Legacy Rails Apps to Rails 3Migrating Legacy Rails Apps to Rails 3
Migrating Legacy Rails Apps to Rails 3
 
The $path to knowledge: What little it take to unit-test Perl.
The $path to knowledge: What little it take to unit-test Perl.The $path to knowledge: What little it take to unit-test Perl.
The $path to knowledge: What little it take to unit-test Perl.
 
Optimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
Optimising Your Front End Workflow With Symfony, Twig, Bower and GulpOptimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
Optimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
 
関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい
 
Railsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshareRailsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshare
 
How Bitbucket Pipelines Loads Connect UI Assets Super-fast
How Bitbucket Pipelines Loads Connect UI Assets Super-fastHow Bitbucket Pipelines Loads Connect UI Assets Super-fast
How Bitbucket Pipelines Loads Connect UI Assets Super-fast
 

Recently uploaded

Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 

Recently uploaded (20)

Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 

How to develop modern web application framework

  • 1. Angelos github.com/dann dann How to develop Modern WAF dann techmemo@gmail.com YAPC::Asia 2009 2009/09/10
  • 2. Angelos github.com/dann dann About Me •Dann •Creator of Angelos •Yet Another WAF •http://github.com/dann/
  • 3. Angelos github.com/dann dann Presentation Overview •What is modern web application framework? •How to develop the minimal elements of modern WAF •How to develop the plugin architecture of WAF
  • 4. Angelos github.com/dann dann What is modern WAF? •Fullstack like Rails •Pluggable like Plagger •Server Abstraction like WSGI •Separete WAF and App Usability Extendability Testability
  • 5. Angelos github.com/dann dann How to develop the basic elements of WAF
  • 6. Angelos github.com/dann dann The basic elements Component ManagerDispatcher Engine recieve a request and return a response (Server Abstraction) URL to Controller resolver Load and search component
  • 7. Angelos github.com/dann dann Basic Sequence of WAF ② ① ③ ④ ⑤ ⑥
  • 8. Angelos github.com/dann dann Engine - Angelos::Engine sub build_engine { my $self = shift; my $request_handler = $self->request_handler; $request_handler ||= $self->build_request_handler; return Angelos::PSGI::Engine->new( interface => { module => $self->server, .... }, psgi_handler => $request_handler, ); } psgi handler which is passed to the server gateay the type of server gateway
  • 9. Angelos github.com/dann dann Engine - Angelos::PSGI::Engine use Mouse; use Angelos::Types qw( ServerGateway );   has 'interface' => (     is => 'ro',     isa => ServerGateway,     coerce => 1, );   has 'psgi_handler' => ( is => 'rw', );   sub run {     my $self = shift;     $self->interface->run( $self->psgi_handler ); } pass psgi handler to server gateway Create Server Gateway
  • 10. Angelos github.com/dann dann Create Server Gateway package Angelos::PSGI::ServerGatewayBuilder; use strict; use warnings; use Plack::Loader; sub build { my ( $class, $module, $args ) = @_; my $server_gateway = Plack::Loader->load( $module, %{$args} ); $server_gateway; } Create server gateway with Plack::Loader
  • 11. Angelos github.com/dann dann psgi handler s code ... sub { my $env = shift; my $req = Angelos::Request->new($env); my $res = $self->handle_request($req); my $psgi_res = $self->finalize_response($res); return $psgi_res; } ... return PSGI response recieve PSGI env and convert it to WAF Request
  • 12. Angelos github.com/dann dann Request Handler - Angelos::Engine::Base sub handle_request { my ( $self, $req ) = @_; eval { $self->DISPATCH($req); }; if ( my $e = Exception::Class->caught() ) { $self->HANDLE_EXCEPTION($e); } # return response return $self->context->res; } ②dispatch request to Dispatcher ①recive a request
  • 13. Angelos github.com/dann dann Dispatching sub DISPATCH { my ( $self, $req ) = @_; my $dispatch = $self->dispatcher->dispatch($req); ... $dispatch->run; # return response $c->res; } ② Dispatch a request do dispatcher
  • 14. Angelos github.com/dann dann Angelos::Dispatcher sub dispatch { my ( $self, $request ) = @_; my $match = $self->router->match($request); my $dispatch = $self->dispatch_class->new( match => $match ); return $dispatch; } ③ <URL to Controller> search controller name based on the request path with HTTP::Router ④ Create dispatch instance
  • 15. Angelos github.com/dann dann Angelos::Dispatcher::Dispatch my $controller = $match->params->{controller}; my $controller_instance = $self- >find_controller_instance( { context => $c, controller => $controller, } ); ... $controller_instance->_dispatch_action( $action, $params ); ⑤ search a controller instance from Component Manager ⑥ execute Controller’s action and return response.
  • 16. Angelos github.com/dann dann Routing HTTP::Router->define( sub { $_->match('/')->to( { controller => 'Root', action => 'index' } ); $_->resources('Book'); } ); conf/routes.pl- define routing information
  • 17. Angelos github.com/dann dann Routing Table .----------------------------------------------+------------+------------+--------------. | path | method | controller | action | +---------------------------------------------+------------+------------+------------+ | / | | Root | index | | /book.{format} | POST | Books | create | | /book | POST | Books | create | | /book.{format} | GET | Books | index | | /book | GET | Books | index | | /book/new.{format} | GET | Books | post | | /book/new | GET | Books | post | | /book/{book_id}.{format} | GET | Books | show | | /book.{format} | POST | Books | create | | /book | POST | Books | create | | /book.{format} | GET | Books | index | | /book.{bookk_id}.{format} | DELETE | Books | destroy | | /book/{book_id} | DELETE | Books | destroy | | /book/{book_id}.{format} | PUT | Books | update | | /book/{book_id} | PUT | Books | update | '-----------------------------------------------+------------+------------+-------------
  • 18. Angelos github.com/dann dann Finished developing basic elements of WAF •It’s really easy to develop basic elements of WAF •You can develop simple WAF like Sinatra in 4 or 5 hours
  • 19. Angelos github.com/dann dann How to develop the plugin architecture of WAF
  • 20. Angelos github.com/dann dann How to development the plugin architecture of WAF • What the plugin architecture of WAF SHOULD be • The type of Plugins • How to develop plugin architecture of WAF • Example: the plugin of Angelos
  • 21. Angelos github.com/dann dann What the plugin architecture of WAF SHOULD • the core elements of WAF should be as small as possible and the all parts of WAF should be extendable and pluggable • The scope of plugin should be limeted • Controller,View, Middleware, Request, Response • Extension point must be declaretive
  • 22. Angelos github.com/dann dann The types of Plugins •Hook WAF’s Lifecycle •Add methods to WAF’s class
  • 23. Angelos github.com/dann dann Plugin Implementation • Hook WAF’s lifecycle • Mouse’s Role + method modifier • Class::Trigger • MouseX::Object::Pluggable • Add methods to WAF’s classes • Mouse’s Role • Exporter • Multiple inheritance
  • 24. Angelos github.com/dann dann How to develop plugin in Angelos • Make Plugin as Role • User consume plugins in the WAF Component • Hook WAF’s lifecycle with method modifier • hook Component’s hook point • Declare hook point method with CAPITAL character
  • 25. Angelos github.com/dann dann Hook point example sub _dispatch_action { my ( $self, $action, $params ) = @_; ... eval { $self->ACTION( $self->context, $action, $params ); }; ... } Declare hook point with Capital character
  • 26. Angelos github.com/dann dann the code of Plugin before 'ACTION' => sub { my ( $self, $c, $action, $params ) = @_; $self->__action_start_time( time() ); }; after 'ACTION' => sub { my ( $self, $c, $action, $params ) = @_; $self->__action_end_time( time() ); my $elapsed = $self->__action_end_time - $self- >__action_start_time; my $message = "action processing time:naction: $action ntime : $elapsed secsn"; $self->log->info($message); };
  • 27. Angelos github.com/dann dann What The WAF developer should do • WAF developer should make default plugin sets which user should use • if there aren’t default plugins sets... • How can I use Unicode in WAF? • ... UseXXX,YYY... • How can I inflate datetime? ...
  • 28. Angelos github.com/dann dann Conclusion • The basic elements of WAF • Engine, Dispatcher, Component Loader • WAF’s plugin • Hook WAF Lifecycle or add a Method to the Component of WAF • Plugin Scope must be limited • the plugin and plugins default sets should be provided by WAF developer
  • 29. Angelos github.com/dann dann Fin. • It’s really easy to implement WAF now • Let’s develop modern WAF with us ;) • Repository • http://github.com/dann/angelos/tree/master