mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-21 15:05:01 +00:00
fix eta handler
This commit is contained in:
@@ -36,6 +36,17 @@ func (o *OSRM) Eta(ctx context.Context, req *pb.EtaRequest, rsp *pb.EtaResponse)
|
|||||||
orig := req.Origin
|
orig := req.Origin
|
||||||
dest := req.Destination
|
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{
|
resp, err := o.Client.Route(ctx, osrm.RouteRequest{
|
||||||
Profile: "car",
|
Profile: "car",
|
||||||
Coordinates: osrm.NewGeometryFromPointSet(geo.PointSet{
|
Coordinates: osrm.NewGeometryFromPointSet(geo.PointSet{
|
||||||
|
|||||||
Reference in New Issue
Block a user