NAME

Web::DataService::Request - interface for handling a single request

SYNOPSIS

The way that you handle a result using Web::DataService is as follows:

my $request = $ds->new_request(undef, $path);
$request->execute;

The new_request method creates a new Web::DataService::Request object, whose attributes are set according to the given path.

The execute method then processes the request as indicated by these attributes; if you have specified class and method, then the appropriate method is called.

METHODS

new ( ds, outer, path )

You will probably not call this method directly; instead, call the new_request method of Web::DataService, which calls it internally after carrying out other processing such as selecting among sub-services.

If you do call it directly, the parameter ds must be an instance of Web::DataService. The parameter outer should be a reference to the request object generated by the underlying Web Application Framework (i.e. Dancer). The parameter path must be the path corresponding to the selected operation.

Returns a new instance of Web::DataService::Request, whose attributes are set from the given path.

execute ( )

Executes this request, and sends a result message using the foundation framework.

clean_param ( param )

Returns the cleaned value of the specified parameter, or undefined if the parameter was not specified. If more than one parameter value was given, the result will be an array ref.

clean_param_list ( param )

Returns a list of one or more values of the specified parameter, or undefined if the parameter was not specified.

result_limit ( )

If the attribute limit_param was specified for the data service, and if it was specified with this request, then the given value is returned. If the parameter was given a value of all, then this method returns undefined.

If the parameter was not specified at all, or if limit_param was never specified, then the default_limit attribute of the data service is returned.

result_offset ( will_handle )

If the attribute offset_param was specified for the data sevice, and if it was specified with this request with a non-zero value, the given value is returned. Otherwise, the method returns 0.

If will_handle is true, then no further processing is done on the result. If will_handle is false, or if result_offset is never called for this request, then (if the request includes the parameter whose name is specified by offset_param, with a numeric value) that number of result records will be dropped before any output is generated.

If the attribute offset_param is not specified for this data service, or if that parameter is not included in the request, then no dropping of records will occur.

sql_limit_clause ( will_handle )

Returns an SQL LIMIT clause which will reflect the values of limit_param and offset_param, if one or both were specified for this data service and if the corresponding parameter(s) were included in this request. Otherwise, returns the empty string.

The argument will_handle is treated exactly as with "result_offset" above.

If the attribute count_param was defined for this data service, and if the corresponding parameter was included in this request, returns the string "SQL_CALC_FOUND_ROWS". Otherwise, returns the empty string.

sql_count_rows ( )

If the attribute count_param was defined for this data service, and if the corresponding parameter was included in this request, executes the SQL statement "SELECT FOUND_ROWS()" and stores the result for later use in generating a response header. Otherwise, it does nothing.

set_result_count ( count )

This method can be used as an alternative to "sql_count_rows". In your own operation methods, you can check for the size of the result set in whatever way is appropriate for your backend and call this method with the resulting number. If you wish, you can do this only if the parameter count_param was included with this request.

add_warning ( message )

Add the specified warning message to this request. The warnings will be automatically included in the result, in a manner appropriate for the selected output format.

warnings ( )

Return a list of the warning messages (if any) that have been added to this request.

output_format ( )

Return the output format that has been selected for this request.

get_request_url ( )

Return the raw (unparsed) URL for this request.

get_base_url ( )

Return the base of the URL for this request. This will generally be of the form http://domain.name/.

get_request_path ( )

Return the remainder of the URL path after the base (but without the format suffix, if any).

set_content_type ( content_type )

Set the response content type. You will probably not need to call this method, since the content type is generally set automatically based on the selected output format.

AUTHOR

mmcclenn "at" cpan.org

BUGS

Please report any bugs or feature requests to bug-web-dataservice at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Web-DataService. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

COPYRIGHT & LICENSE

Copyright 2014 Michael McClennen, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 1333:

Unknown directive: =head