diff options
Diffstat (limited to 'lib/Net')
-rw-r--r-- | lib/Net/HTTP/Spore.pm | 33 | ||||
-rw-r--r-- | lib/Net/HTTP/Spore/Role/Middleware.pm | 5 |
2 files changed, 24 insertions, 14 deletions
diff --git a/lib/Net/HTTP/Spore.pm b/lib/Net/HTTP/Spore.pm index d3b2165..e8c6c28 100644 --- a/lib/Net/HTTP/Spore.pm +++ b/lib/Net/HTTP/Spore.pm @@ -172,19 +172,24 @@ sub _add_methods { This module is an implementation of the SPORE specification. -To use this client, you need to use or to write a SPORE specification of an API. -A description of the SPORE specification format is available at +To use this client, you need to use or to write a SPORE specification of an +API. A description of the SPORE specification format is available at L<http://github.com/SPORE/specifications/blob/master/spore_description.pod> -Some specifications for well-known services are available L<http://github.com/SPORE/api-description>. +Some specifications for well-known services are available +L<http://github.com/SPORE/api-description>. =head2 CLIENT CREATION -First you need to create a client. This can be done using two methods, B<new_from_spec> and B<new_from_string>. The client will read the specification file to create a appropriate methods to interact with the API. +First you need to create a client. This can be done using two methods, +B<new_from_spec> and B<new_from_string>. The client will read the specification +file to create the appropriate methods to interact with the API. =head2 MIDDLEWARES -It's possible to activate some middlewares to extend the usage of the client. If you're using an API that discuss in JSON, you can enable the middleware L<Net::HTTP::Spore::Middleware::JSON>. +It's possible to activate some middlewares to extend the usage of the client. +If you're using an API that discuss in JSON, you can enable the middleware +L<Net::HTTP::Spore::Middleware::JSON>. $client->enable('Format::JSON'); @@ -192,7 +197,7 @@ or only on some path $client->enable_if(sub{$_->[0]->path =~ m!/path/to/json/stuff!}, 'Format::JSON'); -For very simple middlewares, you can simple pass in an anonymous function +For very simple middlewares, you can simply pass in an anonymous function $client->enable( sub { my $request = shift; ... } ); @@ -202,9 +207,9 @@ For very simple middlewares, you can simple pass in an anonymous function =item new_from_spec($specification_file, %args) -Create and return a L<Net::HTTP::Spore::Core> object, with methods -generated from the specification file. The specification file can -either be a file on disk or a remote URL. +Create and return a L<Net::HTTP::Spore::Core> object, with methods generated +from the specification file. The specification file can either be a file on +disk or a remote URL. =item new_from_string($specification_string, %args) @@ -215,15 +220,19 @@ generated from a JSON specification string. =head2 TRACING -L<Net::HTTP::Spore> provides a way to trace what's going on when doing a request. +L<Net::HTTP::Spore> provides a way to trace what's going on when doing a +request. =head3 Enabling Trace -You can enable tracing using the environment variable B<SPORE_TRACE>. You can also enable tracing at construct time by adding B<trace =E<gt> 1> when calling B<new_from_spec>. +You can enable tracing using the environment variable B<SPORE_TRACE>. You can +also enable tracing at construct time by adding B<trace =E<gt> 1> when calling +B<new_from_spec>. =head3 Trace Output -By default output will be directed to B<STDERR>. You can specify another default output: +By default output will be directed to B<STDERR>. You can specify another +default output: SPORE_TRACE=1=log.txt diff --git a/lib/Net/HTTP/Spore/Role/Middleware.pm b/lib/Net/HTTP/Spore/Role/Middleware.pm index 88d64d4..7fe7310 100644 --- a/lib/Net/HTTP/Spore/Role/Middleware.pm +++ b/lib/Net/HTTP/Spore/Role/Middleware.pm @@ -1,6 +1,7 @@ package Net::HTTP::Spore::Role::Middleware; use Moose::Role; +use Class::Load; use Scalar::Util qw/blessed/; has middlewares => ( @@ -16,7 +17,7 @@ has middlewares => ( sub _load_middleware { my ( $self, $mw, $cond, @args ) = @_; - Class::MOP::load_class($mw) unless blessed($mw); + Class::Load::load_class($mw) unless blessed($mw); my $code = $mw->wrap( $cond, @args ); $self->_trace_msg('== enabling middleware %s', $mw); @@ -51,7 +52,7 @@ sub enable_if { confess "condition must be a code ref" if (!$cond || ref $cond ne 'CODE'); if(ref($mw) eq 'CODE'){ # anonymous middleware - Class::MOP::load_class('Net::HTTP::Spore::Middleware'); + Class::Load::load_class('Net::HTTP::Spore::Middleware'); my $anon = Class::MOP::Class->create_anon_class( superclasses => ['Net::HTTP::Spore::Middleware'], methods => { |