Check out the nearest_points function. You can convert the 2 points returned to a new line, and then use union_all to merge the three lines together...