mirror of
https://github.com/openfaas/faas.git
synced 2025-06-09 00:36:46 +00:00
Update example for golang-http
Fixes: #1741 Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
This commit is contained in:
parent
88eea5f62e
commit
2e14a34243
14
README.md
14
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
|
||||
}
|
||||
```
|
||||
|
Loading…
x
Reference in New Issue
Block a user