From 8c0bfd0a1db80ed1ce9f98ed0dc7ce1e3253367b Mon Sep 17 00:00:00 2001
From: Malte Bauch <malte.bauch@stud.h-da.de>
Date: Thu, 3 Mar 2022 14:26:28 +0100
Subject: [PATCH] String replacement for path in GetPath()

A GetPath request triggered from the grpc-gateway proxy needs other
formatting for path. The `||` is replaced back to `/`.
---
 northbound/server/pnd.go | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/northbound/server/pnd.go b/northbound/server/pnd.go
index bb70bf514..3cfdbd6fb 100644
--- a/northbound/server/pnd.go
+++ b/northbound/server/pnd.go
@@ -2,6 +2,7 @@ package server
 
 import (
 	"context"
+	"strings"
 	"time"
 
 	ppb "code.fbi.h-da.de/danet/api/go/gosdn/pnd"
@@ -259,7 +260,11 @@ func (p pndServer) GetPath(ctx context.Context, request *ppb.GetPathRequest) (*p
 		log.Error(err)
 		return nil, status.Errorf(codes.Aborted, "%v", err)
 	}
-	_, err = pnd.Request(duid, request.Path)
+
+	// In case we get the path from grpc-gateway we have to replace
+	path := strings.ReplaceAll(request.Path, "||", "/")
+
+	_, err = pnd.Request(duid, path)
 	if err != nil {
 		log.Error(err)
 		return nil, status.Errorf(codes.Aborted, "%v", err)
-- 
GitLab