fix eta handler

This commit is contained in:
Asim Aslam
2021-04-26 16:06:42 +01:00
parent 263c7bee2a
commit ffa44fd00f

View File

@@ -36,6 +36,17 @@ func (o *OSRM) Eta(ctx context.Context, req *pb.EtaRequest, rsp *pb.EtaResponse)
orig := req.Origin
dest := req.Destination
if o.Client == nil {
u, _ := url.Parse(o.Address)
if u.Scheme == "" {
u.Scheme = "http"
}
o.Client = osrm.NewFromURL(u.String())
}
ctx, cancelFn := context.WithTimeout(context.Background(), time.Second)
defer cancelFn()
resp, err := o.Client.Route(ctx, osrm.RouteRequest{
Profile: "car",
Coordinates: osrm.NewGeometryFromPointSet(geo.PointSet{