# NAME

Web::API::Mapper - Web API Mapping Class

# SYNOPSIS

    my $m = Web::API::Mapper->new(  '/foo' => {
                    post => [
                        '/bar/(\d+)' => sub { my $args = shift;  return $1;  }
                    ]
                    get =>  [ 
                        ....
                    ]
                })->mount( ... );
    my $ret = $m->post->dispatch( '/foo/bar' , { ... args ... } );
    my $ret = $m->get->dispatch(  '/foo/bar' );
    my $ret = $m->dispatch( '/foo/bar' , { args ... } );

    $m->post->mount( '/foo' , [ '/subpath/to' => sub {  ....  } ]);
    $m->mount( '/fb' => {  post => [  ... ] , get => [  ... ] }  )->mount( ... );

# TODO

Provide classes for mounting service to frameworks.

# DESCRIPTION

[Web::API::Mapper](http://search.cpan.org/perldoc?Web::API::Mapper) is an API (Application Programming Interface) convergence class for mapping/dispatching 
API to web frameworks.

by using [Web::API::Mapper](http://search.cpan.org/perldoc?Web::API::Mapper) you can simply mount these api service like
Twitter, and dispatch paths to these services.

[Web::API::Mapper](http://search.cpan.org/perldoc?Web::API::Mapper) is using [Path::Dispatcher](http://search.cpan.org/perldoc?Path::Dispatcher) for dispatching.

# ROUTE SPEC

API Provider can provide a route hash reference for dispatching rules.

- post => [ '/path/to/(\d+)' => sub {  } , ... ]

- get => [  '/path/to/(\d+)' => sub {  } , ... ]

- fallback => sub {    }

# ACCESSORS

## route

## post

is a [Web::API::Mapper::RuleSet](http://search.cpan.org/perldoc?Web::API::Mapper::RuleSet) object.

## get

is a [Web::API::Mapper::RuleSet](http://search.cpan.org/perldoc?Web::API::Mapper::RuleSet) object.

## fallback

is a CodeRef, fallback handler.

# FUNCTIONS

## mount

## dispatch

# EXAMPLE

    package Twitter::API;

    sub route { {
        post => [
            '/timeline/add/' => sub { my $args = shift;  .... },
        ],
        get => [
            '/timeline/get/(\w+)' => sub {  my $args = shift;  .... return $1 },
        ],
    } }

    package main;

    # This will add rule path to /twitter/timeline/add/  ... etc
    my $m = Web::API::Mapper->new( '/twitter' => Twitter::API->route );
    $m->mount(  '/basepath' , {  post => [  ... ] } );
    $m->post->mount( '/basepath' , [  ...  ]  );
    $m->dispatch( '/path/to' , { args ... } );

    1;

# AUTHOR

Cornelius & cornelius.howl at gmail.com ;