So in REST I have a product resource...
http://api/product
Question is what if I've got some domain logic? In an Object Oriented world, I might have
public class product
{
int id;
public product(){}
public int Calc(int first, int second)
{
return first + second;
}
}
How do I represent this business logic? I assume I can do...
public int GetCalc(int id, int first, int second)
{
localProduct = products[id];
return localProduct(first + second);
}
Hence the URL of the service would become
http://api/product/Calc?id=1&first=1&second=2
OR (alternatively)
http://api/product/1/Calc?first=1&second=2
This returns the correct result.... I'm just wondering if this is how I should represent business business logic? Or should I be doing this a different way or trying to avoid it altogether? I'd welcome any ideas on how to improve this...