datacratic/soa — pull request #131 by jeremybarnes (2014-09-15 02:34:59+00:00)
Title: Added connection and request parameters to extractObject, and checked if...

... it had sent a response before continuing (PLAT-673)

Sample use (from platform):

// Verify that the given subject is indeed present in the behaviour domain
auto verifySubject = [=] (const RestServiceEndpoint::ConnectionId & connection,
const RestRequest & request,
RestRequestParsingContext & context)
{
// Grab the dataset
Dataset & dataset = context.getObjectAs();

// Find the subject we just parsed from the path
string subject = context.resources.back();

//cerr << "subject = " << subject << endl;

SH sh = SH::fromString(subject);

bool exists = dataset.behs->knownSubject(sh);

if (!exists && request.verb != "PUT") {
Json::Value error;
error["error"] = "subject '" + subject + "' doesn't exist in dataset";
connection.sendResponse(404, error);
}
};

auto & subject
= subjects.addSubRouter(Rx("/([^/]*)", "/"),
"operations on an individual subject",
verifySubject);