I'm working on Language level interfaces to web API's. These libraries are of course built around existing HTTP Request/Reply interfaces. I see myself as having a few options
submit method on the request object e.g
my $req = Request->new( ... ); my $response = $req->submit; # returns response my $res2 = $req->submit; # sends the same request again
lazy request accessor
my $req = Request->new( ... ); my $response = $req->response; # returns a reference to the response my $res2 = $req->response; # doesn't send again, just returns the reference $req->clear_response; # clears the response value my $res3 = $req->response; # sends again because no response exists
These are the 2 options I'm thinking of. I have seen more examples of the former but I'm not sure if there's a reason why. Do you have any preferences on which style interface? or are there other ways I'm not thinking of? Overall I'm trying to discern what the best API is to retrieve the response.