In a routing application,probably using osm as base layer, how do I get a line-string that goes through the road and not directly from one point to another?
Is there any software,like an API?
I have seen pgRouting will it do the road?
Do I need to downlaod any data?
So for example I have this situation where point A is a starting geometry point and B is the ending geometry point and the black line is the road:

If I want to use a layer with a linesting feature from Point A to B it will look like this: (the red line is the linestring and the black one is the road.)

But what I want is the linestring to follow the road like this:

Suppose that the red like goes exactly like the black line and completely follows the road without us adding any other geometry points other than A and B!
Note that I am using OpenLayers API and I am not asking for a whole routing package, I would like to know how to connect geometry point with 'road' or 'highway' nodes.