From 2e14a34243181b9f8145fab85edca5f55999bf45 Mon Sep 17 00:00:00 2001 From: "Alex Ellis (OpenFaaS Ltd)" Date: Wed, 13 Jul 2022 14:32:33 +0100 Subject: [PATCH] Update example for golang-http Fixes: #1741 Signed-off-by: Alex Ellis (OpenFaaS Ltd) --- README.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c0477904..2f3452da 100644 --- a/README.md +++ b/README.md @@ -79,19 +79,21 @@ Official templates exist for many popular languages and are easily extensible wi package function import ( - "log" + "fmt" + "net/http" - "github.com/openfaas-incubator/go-function-sdk" + handler "github.com/openfaas/templates-sdk/go-http" ) + // Handle a function invocation func Handle(req handler.Request) (handler.Response, error) { var err error + message := fmt.Sprintf("Body: %s", string(req.Body)) + return handler.Response{ - Body: []byte("Try us out today!"), - Header: map[string][]string{ - "X-Served-By": []string{"openfaas.com"}, - }, + Body: []byte(message), + StatusCode: http.StatusOK, }, err } ```