Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Sample REST request & response code

by 1nickt (Canon)
on Sep 06, 2018 at 11:41 UTC ( [id://1221869]=note: print w/replies, xml ) Need Help??


in reply to Sample REST request & response code

Hi, there's sample code in the documentation of any decent CPAN module, in the SYNOPSIS as well as in the test files. Larger platforms such as web application servers typically offer expansive documentation. Which have you looked at so far?

I recommend using Dancer2 to serve your REST API, and you might like REST::Client for making requests to it.

Server:

use Dancer2; get '/' => sub { "Hello World" }; dance;
Client:
use REST::Client; my $client = REST::Client->new(); $client->GET('http://localhost:3000/'); print $client->responseContent();

Hope this helps!


The way forward always starts with a minimal test.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1221869]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (2)
As of 2024-04-25 21:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found