Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion rest/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ TOPDIR := ..
BUILD_DIR ?= $(TOPDIR)/build

GO ?= go
TRANSLIB_LDFLAGS ?=
ifeq ($(strip $(ENABLE_TRANSLIB_ROLLBACK)),y)
TRANSLIB_LDFLAGS += -X github.com/Azure/sonic-mgmt-common/translib.ENABLE_TRANSLIB_ROLLBACK=true
endif
GOROOT ?= $(shell $(GO) env GOROOT)

REST_BUILD_DIR := $(BUILD_DIR)/rest_server
Expand Down Expand Up @@ -59,7 +63,7 @@ $(REST_BIN): $(REST_SRCS) | $(REST_BUILD_DIR)/
ifeq ($(SONIC_COVERAGE_ON),y)
$(GO) test -mod=vendor -coverpkg="./..." -c -o $@ ../rest/main/main.go ../rest/main/main_test.go
else
$(GO) build -mod=vendor -gcflags="all=-N -l" -v -o $@ ../rest/main/main.go
$(GO) build -mod=vendor -gcflags="all=-N -l" -v -o $@ -ldflags "$(TRANSLIB_LDFLAGS)" ../rest/main/main.go
endif

# Gotest binary for REST Server
Expand Down
12 changes: 9 additions & 3 deletions rest/server/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,10 @@ func invokeTranslib(args *translibArgs, rc *RequestContext) (int, []byte, error)
resp, err1 := translib.Get(req)
if err1 == nil {
status = 200
content = []byte(resp.Payload)
for _, iter := range resp {
byteresp := []byte(iter.Payload)
content = append(content, byteresp...)
}
} else {
err = err1
}
Expand Down Expand Up @@ -367,8 +370,11 @@ func invokeTranslib(args *translibArgs, rc *RequestContext) (int, []byte, error)
}
res, err1 := translib.Action(req)
if err1 == nil {
status = 200
content = res.Payload
status = 200
for _, iter := range res {
byteresp := []byte(iter.Payload)
content = append(content, byteresp...)
}
} else {
err = err1
}
Expand Down