Update example for golang-http

Fixes: #1741

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
This commit is contained in:
Alex Ellis (OpenFaaS Ltd) 2022-07-13 14:32:33 +01:00
parent 88eea5f62e
commit 2e14a34243

View File

@ -79,19 +79,21 @@ Official templates exist for many popular languages and are easily extensible wi
package function package function
import ( 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) { func Handle(req handler.Request) (handler.Response, error) {
var err error var err error
message := fmt.Sprintf("Body: %s", string(req.Body))
return handler.Response{ return handler.Response{
Body: []byte("Try us out today!"), Body: []byte(message),
Header: map[string][]string{ StatusCode: http.StatusOK,
"X-Served-By": []string{"openfaas.com"},
},
}, err }, err
} }
``` ```